Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 14
    This might be the correct way to go, but I still think it's stupid. The HTML-devs foresaw the need for a <code> tag, but decided we'd only ever write one-line? Or I guess, because they didn't want to have two tags, one block and one inline? Still... what's wrong with making <code> block-level with CSS? I thought we were supposed to write "semantic" HTML. <code> is good and semantic, but <pre> not so much. Commented Jan 6, 2011 at 8:43
  • 13
    I disagree. The opposite of preformatted text is just plain old text in your document. Making <code> block-level with CSS is unsemantic. This way is recommended in HTML5. Commented Jan 6, 2011 at 14:11
  • 2
    Problem with <pre> is it modifies whitespace processing as well: all spaces are preserved, and wrapping is switched off. Unless there's a way to switch this off? Commented Jan 8, 2011 at 23:55
  • 5
    @Steve Bennett, in CSS white-space: normal; Though I fail to see why you would do this for code. Also this <pre><code> thing is stupid, the <pre> tag is defined very clearly in the standards as "computer code" (and other things) as mentioned by @jleedev. Is it because you think <code> is a better name? sorry that doesn't make it more semantic. There's a similar case with the tag <address>, it doesn't really sound like "author", but the standard says that's what it's for, so it-is. Commented Feb 23, 2011 at 2:15
  • 9
    -1. The OP's central question was about how to accomplish block snippets that wrap. You've addressed inline code, as well as block code that must not wrap, but this doesn't address the OP's primary question. Commented May 31, 2013 at 0:51