Hey #WebDevs. Got an #HTML question.
When combining the code and pre tags, which one should go inside which?
Should it be <code><pre> ... </pre></code>, or <pre><code> ... </code></pre>.
I need to do both because the code in question might have line breaks, so pre will ensure that those are rendered correctly.
It seems to work either way. pre on the outside adds some extra margin, I think. I didn't look at it too closely.
But, I'm not sure which is the more correct way.
I found my answer, according to MDN.
The
<pre>tag allows as children any "phrasing content".<code>is included in that. So,<pre><code> ... </code></pre>is valid.However,
<code>also allows "phrasing content" as children. And<pre>is not included in that. So<code><pre> ... </pre></code>is invalid.