W3C home > Mailing lists > Public > www-validator@w3.org > October 2002

Re: HTML validator indicates false positives?

From: Ian Hickson <ian@hixie.ch>
Date: Fri, 25 Oct 2002 08:54:31 +0000 (GMT)
To: "nex@o-slash.org" <nex@o-slash.org>
Cc: "www-validator@w3.org" <www-validator@w3.org>, Olivier Thereaux <ot@w3.org>
Message-ID: <Pine.LNX.4.21.0210250842520.15289-100000@dhalsim.dreamhost.com>

On Thu, 24 Oct 2002, nex@o-slash.org wrote:
>
> when i validated the project antville site [1] with the HTML validator, 

   http://project.antville.org/

Note that this is an HTML 4.0 Transitional document.

> 1: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
>     "http://www.w3.org/TR/REC-html40/loose.dtd">
> 2: <html>
> 3: <head>
> 4: <title>Project Antville</title>
> 5: <meta name="MSSmartTagsPreventParsing" content="TRUE">
> 6: <link rel="alternate" type="text/xml" title="XML"
>     href="http://project.antville.org/rss10" />
> [...]
> 10: </head>
> --->8---
> looking at this, i cannot explain this error message:
> > Line 10, column 6: Error: end tag for element "HEAD" which is not open;
> > try removing the end tag or check for improper nesting of elements

This is a correct error message.

Line 6 is the culprit.

In SGML,

   <foo/.../

...is short for 

   <foo>...</foo>

However, if <foo> has no end tag, then

   <foo/

...is all that is required, and anything afterwards is considered content
coming after the element.

In HTML the <link> element accepts no end tag.

Therefore

   <link .../

...is equivalent to

   <link ...>

Now if you look at your document, you'll see that just after the slash is
another character:

   <link .../>

This character is not part of the element. Indeed the following is exactly
equivalent:

   <link ...>&gt;

Now, character data isn't allowed in the <head>, so the character implies
a </head> close tag and a <body> open tag (both of these tags are labelled
as optional). Therefore it is actually equivalent to:

   <link ...></head><body>&gt;

When the validator later comes across the real </head> close tag, it is
considered an error, since the </head> close tag has already been implied.


Note that this is yet another reason to avoid using XHTML when sending
content as text/html. XHTML is _not_ HTML-compatible.

-- 
Ian Hickson                                      )\._.,--....,'``.    fL
"meow"                                          /,   _.. \   _\  ;`._ ,.
http://index.hixie.ch/                         `._.-(,_..'--(,_..'`-.;.'
Received on Friday, 25 October 2002 04:54:35 GMT

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