Code


displayunchanged positionunchanged z-indexunchanged font-size scalingyes breakpointsno

Class list

  • .snippet
  • .code

Description

Use a .snippet to highlight a piece of text and have it be styled as code. Use a .code for an entire block of code.

Be sure to use HTML character entities where appropriate.

Snippet

Lorem ipsum x = 42; dolor amet.

<p>Lorem ipsum <span class="snippet">x = 42;</span> dolor amet.</p>

The .snippet has its display property set to inline-block.

Code

Thanks to the pre element, the white space is preserved when writing out your code.

function sayHello() {
    console.log('Hello.');
}
<pre class="code"><code>function sayHello() {
    console.log('Hello.');
}</code></pre>

Font size scaling

Use the font-size utility classes to adjust the size of a .code.

function sayHello() {
    console.log('Hello.');
}
<pre class="code h6"><code>function sayHello() {
    console.log('Hello.');
}</code></pre>