Skip to main content
2 of 3
added 2 characters in body
slhck Mod
  • 232.5k
  • 4
  • 79
  • 150

The padding of the <code> element is set to 1px 5px 1px 5px, thus indenting the left and right by five pixels. This makes sense because inline code needs to be properly spaced and it'd look weird without the padding.

Why does it look weird when using it for multiple lines? Because <code> is not meant for that. <code> is for inline formatting. You should use <pre></pre> instead if you want a block element.

Compare the incorrect backtick / <code> variant:

<code>multiline  
foo</code>

Which renders as:

multiline
foo

And the correct:

<pre>
multiline
foo
</pre>

Which renders as:

multiline
foo

Always use the latter for multiline code.

slhck Mod
  • 232.5k
  • 4
  • 79
  • 150