Re: Explain this please.

by "Darrell King" <darrell(at)webctr.com>

 Date:  Sun, 26 May 2002 15:44:45 -0400
 To:  <hwg-techniques(at)hwg.org>
 References:  ntlworld
  todo: View Thread, Original
So, this means that empty elements (such as meta and link tags) should not
be closed within the head section?  Or are they not classed as empty
elements?

D

----- Original Message -----
From: "Andrew McFarland"

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.

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