Re: Explain this please.

by Andrew McFarland <aamcf(at)aamcf.co.uk>

 Date:  Sun, 26 May 2002 20:11:52 +0100
 To:  <hwg-techniques(at)hwg.org>
 In-Reply-To:  ais
  todo: View Thread, Original
At 12:57 26/05/02 -0500, Linda Mercer/Wishstar wrote:
>While the page http://www.xumbrus.com/order.htm validates with TIDY in 
>HTML-Kit, it does NOT validate with using the WC3 validation service. What 
>gives? I don't SEE a problem. (BTW, if I remove the closings from the 
>metatags (" /> changed to ">) - it still says there are the same errors 
>and still says <body> is not allowed after </head>.

This is what is causing the problem:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

Believe it or not, in HTML that is actually equivalent to

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> >

HTML allows the awful SHORTTAG constructs, which (among other things) allow 
you to write opening tags as <foo/. That means to a full HTML parser (like 
the validator, but unlike most browsers) the opening tag closes at the `/'

HTML also allows the omission of the </head> tag, and a full HTML parser 
will assume a </head> when it first encounters content that can only exist 
in the body. The bare `>' is PCDATA, which cannot be directly in the head, 
so the validator (correctly) assumes a closing head tag and opening body 
tag exist.

To the validator, the line:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

is really

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>

That means, when your next META comes along it is actually in the body, not 
the head. The validator is correct here; I don't know why HTML kit doesn't 
worry, but its probably because it doesn't know about SHORTTAGS.

Andrew

--
http://aamcf.co.uk/

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA