[whatwg] Pre, code and semantics in HTML5: Wishful thinking?

Edward Z. Yang edwardzyang at thewritingpot.com
Sun Jun 22 13:22:40 PDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I was reading through the HTML5 spec the other day and I noticed this
tidbit:

> To represent a block of computer code, the pre element can be used
> with a code element; to represent a block of computer output the pre
> element can be used with a samp element. Similarly, the kbd element
> can be used within a pre element to indicate text that the user is to
> enter.

The implication is that document authors are recommended to use
<pre><code> to wrap all of their programming code instead of a lone
<pre>, if they wish to be fully semantic. This feels needlessly verbose
and abusive of <code>, which traditionally has been used to mark
single-liners.

It also makes it extremely difficult to style pre as a block for code,
as the only semantic indication that the contents of the pre block are
computer code is its child. You'd end up having to say <pre
class="code"><code> if you wanted to style pre as well.

At the same time, I still think the semantics of whether or not a <pre>
tag indicates a plaintext file, or a piece of ASCII art, or computer
code, is somewhat important. However, I think this information would be
more appropriately given as an attribute.

Thanks for reading,
Edward

P.S. Please CC my address on all replies.

- --
 Edward Z. Yang                        GnuPG: 0x869C48DA
 HTML Purifier <http://htmlpurifier.org> Anti-XSS Filter
 [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIXrSQqTO+fYacSNoRAn1WAJ95X7i0Rf4sMGuj4n5qEEWoEH4CuwCfUnP8
TIADRZ6VRXWK2AC9tIATl8E=
=TY06
-----END PGP SIGNATURE-----



More information about the whatwg mailing list