Re: How to markup sample code.

> 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