Hacker News new | past | comments | ask | show | jobs | submit login

That's a strange version of "required". Basically the elements are not required in a document until parse time at which point they are inserted following an extremely arduously defined algorithm.

It seems bizarre to me that you wouldn't simply define the location of meta elements strictly as being in the head but instead define that should the parser find them they should be wrapped in to a head element.

On a brief view it looks like one can just drop a meta tag, say, in anywhere in the document and the parser has to move this to the head element?

I didn't realise that they were encouraging tag soup; this isn't part of the spec I've seen before. This sort of complex parsing algo wasn't in XHTML1.X or HTML4.X was it?




You can see the HTML 4.01 definitions at http://www.w3.org/TR/html401/struct/global.html#h-7.3

The complex parsing algorithm wasn't spelled out in excruciating detail, as it is in HTML5; much of it was implied, and left for the parser developers to figure out.

Strictly, the HTML, HEAD, and (BODY|FRAMESET) elements are required, in a valid document, but the tags delimiting them are optional. That way, code which manipulates the DOM can always count on a HEAD element being present, and CSS specifiers can use 'body' as a root, even if the tags themselves are missing from the source HTML file.

The first actual required tag in an HTML 4 document is <title>, as far as I know. Every HTML document has to have one, and it needs to be opened and closed explicitly. If it's the first thing in the document, it implies an <html><head> before it, and if body content comes after it, that will imply </head><body> as well.

You could put a <meta> tag anywhere before the first body content, and it would still be part of the implied HEAD element. As long as it doesn't come after the (explicit or implicit) </head> tag, it shouldn't cause the document to fail validation.

And no, none of this is valid XHTML. XHTML is always strict, and all opening and closing (or self-closing) tags must be present in the source file.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: