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 {

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 {

[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>
Received on Thursday, 11 July 2002 17:28:47 UTC

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