[whatwg] </html> with omitted tags
foolistbar at googlemail.com
Fri Dec 26 09:17:48 PST 2008
On 26 Dec 2008, at 17:02, Calogero Alex Baldacchino wrote:
> Philip Taylor ha scritto:
>> I can start with a simple document that's probably conforming and
>> the validator doesn't complain about:
>> <!DOCTYPE html><html><head><title></title></head><body></body></
>> Then I can read the "Writing HTML document: Optional tags" section,
>> which says:
>> "A head element's end tag may be omitted if the head element is not
>> immediately followed by a space character or a comment.
>> A body element's start tag may be omitted if the first thing inside
>> the body element is not a space character or a comment, except if the
>> first thing inside the body element is a script or style element.
>> A body element's end tag may be omitted if the body element is not
>> immediately followed by a comment."
>> So I choose to omit the </head><body></body> because I think those
>> rules say I can do so. I get:
>> <!DOCTYPE html><html><head><title></title></html>
>> But now I get a parse error, which I think is because the </html>
>> comes in the "in head" insertion mode and is "Any other end tag:
>> error. Ignore the token.", so something seems wrong.
> AIUI, omitting those closing tags is a parse error anyway, but in
> certain situations the parser can fix the code automatically because
> the state to enter/remain in is unambigous. Thus a validator
> notifies a parse error, while a browser keeps the error internally
> and handles it when possible.
The writing HTML documents section is meant to give what is a
conforming HTML document, and those documents are conforming according
to that. However, conformance checkers which are meant to follow the
parser section (and throw the parse errors that produces) which in
these cases differs. Therefore, either the writing section is wrong or
the parser is wrong to throw the parse errors.
More information about the whatwg