Re: HTML validator indicates false positives?

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 UTC