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

How to markup sample code.

From: Satoshi ISHIKAWA <pastelsbadges@nyc.odn.ne.jp>
Date: Fri, 12 Jul 2002 06:26:16 +0900
To: <www-html@w3.org>
Message-ID: <B9542707.656%pastelsbadges@nyc.odn.ne.jp>

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?

HTML 2.0 [1] says :

> The CODE element is intended for short words or phrases of code;
> the PRE block structuring element (section Preformatted Text: PRE)
> is more appropriate for multiple-line listings.

HTML 3.2 [2] says:

> CODE: used for extracts from program code

HTML 4.01 [3] says:

> CODE: Designates a fragment of computer code.

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>


[1] http://www.w3.org/MarkUp/html-spec/html-spec_5.html#SEC5.5.2
[2] http://www.w3.org/TR/REC-html32#phrase
[3] http://www.w3.org/TR/html4/struct/text.html#h-9.2.1

-- 
Satoshi ISHIKAWA <pastelsbadges@nyc.odn.ne.jp>
http://math.oheya.to/markup/
Received on Thursday, 11 July 2002 17:28:47 GMT

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