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 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:06:00 UTC