[whatwg] </html> with omitted tags

Calogero Alex Baldacchino alex.baldacchino at email.it
Fri Dec 26 09:02:44 PST 2008


Philip Taylor ha scritto:
> I can start with a simple document that's probably conforming and that
> the validator doesn't complain about:
>
>   <!DOCTYPE html><html><head><title></title></head><body></body></html>
>
> 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: Parse
> 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.

AIUI, a brower would notice the error but might ignore it since both in

<!DOCTYPE html><html><head><title></title></html>

and in

<!DOCTYPE html><html><head><title></title></head><body></body></html>

there is nothing to show but the background color of the <html> root 
element as provided by default style sheets (that is, they're 
equivalent), whereas finding a "showable" start tag (like a <p>) would 
lead (about) to automatic insertions of </head> and <body> and to 
reconsume the tag as "in body" insertion mode.

Indeed, section 8.1 says,

/'This section only applies to documents, authoring tools, and markup 
generators. In particular, it does not apply to conformance checkers; 
conformance checkers must use the requirements given in the next section 
("parsing HTML documents").'

///thus section "8.1.2.4 Optional tags" does not apply to validators. ;-)

[ space characters and comments may be handled correctly anyway, but 
omitting the </head> tag would result in a different document tree, thus 
athors and authoring tools should take care that

<!DOCTYPE html><html><head><title></title><!-- this is a comment --></html>

and

<!DOCTYPE html><html><head><title></title></head><!-- this is a comment --></html>

are not fully equivalent ]
 
 
 --
 Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f
 
 Sponsor:
 Polizza auto?
* Garanzia furto e incendio per un anno al vantaggioso prezzo di 30 euro tasse incluse! Affrettati, hai tempo fino al 31 Dicembre!
* 
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8510&d=26-12



More information about the whatwg mailing list