Code elements

The <code> and <pre> elements are for displaying inline and multiline blocks of code.

In this article

Usage

Use the <code> element for inline code snippets.

<p class="mb-0">The <code>push()</code> method adds one or more elements to the end of 
  an array and returns the new length of the array.</p>

Use the <pre> element for multiple lines of code.

  L          TE
    A       A
      C    V
       R A
       DOU
       LOU
      REUSE
      QUE TU
      PORTES
    ET QUI T'
    ORNE O CI
     VILISÉ
    OTE-  TU VEUX
     LA    BIEN
    SI      RESPI
            RER       - Apollinaire
<pre class="my-0">
  L          TE
    A       A
      C    V
       R A
       DOU
       LOU
      REUSE
      QUE TU
      PORTES
    ET QUI T'
    ORNE O CI
     VILISÉ
    OTE-  TU VEUX
     LA    BIEN
    SI      RESPI
            RER       - Apollinaire
</pre>

Use <kbd> for input that is typically entered via keyboard.

To edit settings, press <kbd>ctrl</kbd> + <kbd>s</kbd>

Customization

The $code_font theme setting determines the font family to use for code elements.

The following Sass variables are available in the theming framework:

Variable Description
$padding-code The padding applied to the <code> element.
$color-code The color of the <code> element.
$bg-color-code The background color of the <code> element.
$border-radius-code The border radius applied to the <code> element.
$padding-pre The padding applied to the <pre> element.
$margin-pre The margin applied to the <pre> element.
$bg-color-pre The background color of the <pre> element.
$padding-kbd The padding applied to the <kbd> element.
$color-kbd The color of the <kbd> element.
$bg-color-kbd The background color of the <kbd> element.
$font-size-kbd The font size of the <kbd> element.
$shadow-kbd The box shadow applied to the <kbd> element.

Questions or feedback about this article? Let us know