W3C home > Mailing lists > Public > www-validator@w3.org > January 2004

Re: W3C validator disallows the <pre> tag

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Mon, 26 Jan 2004 12:20:00 +0200 (EET)
To: Matitiahu Allouche <matial@il.ibm.com>
Cc: www-validator@w3.org
Message-ID: <Pine.GSO.4.58.0401261209540.25033@korppi.cs.tut.fi>

On Mon, 26 Jan 2004, Matitiahu Allouche wrote:

> In a file that I submitted for validation, the W3C Validator flagged the
> <pre> tag with the following message:
>
> document type does not allow element "PRE" here; missing one of "APPLET",
> "OBJECT", "MAP", "IFRAME", "BUTTON" start-tag

The important word is "here". The element occurs in a context where it
is not allowed. For example, <font ...><pre> is not allowed, since
a <font> element must not contain a <pre> element.

(As usual, posting the URL would have helped to pinpoint the specific
problem.)

> This tag is defined in section 9.3.4 of the 4.01 HTML specification, where
> it does not seem to be related to applet, object, iframe or button tags.

It is defined there and contained in all DOCTYPEs, but the content models
of other elements define the contexts where the <pre> element may appear.

The reference to "APPLET" etc. has confused many people, and it probably
results from the internals of the validator's parser. The parser's error
reporting tries to be clever: after noticing <pre> inside <font> for
example, it analyzes what _intervening_ markup might possibly make
the document valid, and e.g. <font ...><applet ...><pre>...</pre>
</applet></font> would be valid. This does not, of course, imply that it
would make sense, or even be correct by HTML specifications.

-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/
Received on Monday, 26 January 2004 05:20:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:10 GMT