Re: Too much info on auto-closing META tags - confusing

On Mon, Oct 18, 2004 at 02:10:31PM +0200, Pim Blokland wrote:
> I've read all about it, and now I'm even less sure than before.
> My question is: are auto-closing META tags like this
> 
> <meta name="x" content="x" />
> 
> valid HTML 4.01 strict (even if the W3 validator says they aren't)?

The short answers are that "It is wrong to use XHTML style
self-closing tags in HTML" and that "The Validator is correct".

The long answer is that it may or may not be *valid* depending on
where you use it.

In HTML <foo /> (effectively) means the same as <foo>&gt;. 

Character data (i.e. &gt; or 'Hello, world') is not allowed within the
<head>.

However, the end tag for head and the start tag for body are optional.

So this is valid:

<title>Foo</title>
<meta name="x" content="x" />
<h1>Wibble</h1>

as it means the same as

<head>
<title>Foo</title>
<meta name="x" content="x">
</head><body>
&gt;
<h1>Wibble</h1>

The only browser I know that might respect this is Emacs w3-mode, so
its very badly supported and something you probably wouldn't want to
do anyway.

-- 
David Dorward                                      http://dorward.me.uk

Received on Monday, 18 October 2004 15:32:57 UTC