Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>That's the difference between <a href="http://www.w3.org/TR/html4/struct/global.html#h-7.5.3" rel="noreferrer">block and inline</a> elements. <a href="http://www.w3.org/TR/html4/sgml/dtd.html#block" rel="noreferrer"><code>pre</code> is a block level element</a>. It's not legal to put it inside a <code>code</code> tag, which <a href="http://www.w3.org/TR/html4/struct/text.html#h-9.2.1" rel="noreferrer">can only contain inline content</a>.</p> <p>Because browsers have to support whatever godawful tag soup they might find on the real web, Firefox tries to do what you mean. IE happens to handle it differently, which is fine by the spec; behavior in that case is unspecified, because it should never happen.</p> <ul> <li>Could you instead <em>replace</em> the <code>code</code> element with the <code>pre</code>? (Because of the block/inline issue, technically that should only work if the elements are inside <a href="http://www.w3.org/TR/html4/sgml/dtd.html#flow" rel="noreferrer">an element with "flow" content</a>, but the browsers might do what you want anyway.)</li> <li>Why is it a <code>code</code> element in the first place, if you want <code>pre</code>'s behavior?</li> <li>You could also give the <code>code</code> element <code>pre</code>'s whitespace preserving power with the CSS <a href="http://www.blooberry.com/indexdot/css/properties/text/whitespace.htm" rel="noreferrer"><code>white-space: pre</code></a>, but apparently <a href="http://www.quirksmode.org/css/whitespace.html" rel="noreferrer">IE 6 only honors that in Strict Mode</a>.</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload