W3C home > Mailing lists > Public > www-html@w3.org > July 2002

Re: How to markup sample code.

From: Marc Görtz <Privat@MarcGoertz.de>
Date: Fri, 12 Jul 2002 00:03:45 +0200
Message-ID: <001501c22926$eec243c0$a800a8c0@neuromancer>
To: <www-html@w3.org>

> In most of W3C specification, long sample code is marked
> by <pre>...</pre>, without <code>...</code>.
> But I usualy markup such code as:
>
>   <pre><code>a {
>     text-decoration:underline;
>   }</code></pre>
>
> This markup is bad?

Well, I'd use the SAMP element because it's a sample. Maybe even
<pre><samp><code>...</code></samp></pre> is the right thing. :o)

> [Excerpts from HTML2, HTML3.2 and HTML4.01]
>
> These description means that <code> shouldn't be used for
> *long* or *entire* computer code? Should I mark it as follows?
>
>   <pre>a {
>     text-decoration:underline;
>   }</pre>

If it's described this way in the recommendation, why not take this
recommendation by word and do so? IMHO the PRE element seems to be the right
choice for longer code samples _as_ said by the spec. But it's not clear for
a machine that this is a code fragment (or even a sample). If you want to
have a clear and machine-readable HTML source, you should provide help for
these agents by using the CODE element.

--
Marc Görtz (7-Bit: Marc Goertz) | Media Designer
<mailto:Privat@MarcGoertz.de>   | <http://www.marcgoertz.de/>
Received on Thursday, 11 July 2002 18:04:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:52 GMT