Marking up blocks of code

Paul Hammond is wondering how to mark up blocks of code in HTML. He references a few methods, such as <pre>...</pre>, or <p><code>...</code></p>. His worries with the first method are that preformatted text destroys layouts, and that it’s an uneasy mix of presentation and markup. I can’t help the first, but I’m more prepared to have a layout broken than I am to have code break onto two lines, since an awful lot of languages are intolerant of that sort of thing. My solution to this when I post code blocks is <pre><code>...</code></pre>. I’ve seen people set \<code> to display: block in stylesheets, but that breaks if you want to write some code inline (as with that little CSS snippet just there).

None

More in the discussion (powered by webmentions)

  • (no mentions, yet.)