Pre tags in comments

Monday 21 July 2008

Just a quick note: after far too long, the comments on this blog now support the <pre> tag so we can talk about code if need be. Thanks for your patience!





Why not use the <code> element for code?

# Using code element
import this
if 1:
print 'abc'

# Using pre element
import that
if 1:
    print 'abc'


That's good news, because I thought I was coming down with a code...


I didn't use <code> because it's one of those relics from HTML that I forgot even existed. Why not use <samp>? <pre> covers it all, and has the advantage that it also implies not flowing text, which is important. I wanted to give people *a* way to do what they need, not *all* ways.


Sorry, was just meant to be a friendly suggestion.

BTW, from the HTML spec: SAMP:
Designates sample output from programs, scripts, etc.

Anyway, please don't let my noise distract from your excellent blog.


And anyway, I think <code> is supposed to be used for inline text, not for blocks. If I remember correctly, at least.


                  _______                         ________________________
                 /    ___\_             o  O  O _( I wonder if Ned knows  )____
                /====(_____\___---_  o        _(  that he's opened up his blog )
               |                    \        (_ to all kinds of abuse.  ______)
               |                     |@        (_______________________)
                \       ___         /
   \ __----____--_\____(____\_____/
   /              /    \____/)_
                /        ______)
               /           |  |
              |           _|  |
        /                    *   *   \
       /   *     *                    \
      / *                              \
          |                        |
          |                        |



You are quite right. I'll shut up now.

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.