[whatwg] Handling <title> inside <body>

On Mon, 10 Nov 2008 11:51:34 +0100, Tommy Thorsen <tommy at kvaleberg.com>  
wrote:

> I noticed that, according to the html5 algorithm, when the parser sees a  
> <title> start tag when in the "in body" insertion mode, it's not  
> supposed to relocate it to the head element. Opera matches this  
> behaviour, but Firefox moves any title tag  it finds into the head  
> element.

HTML5 used to match Firefox, but changed since, IIRC, Mozilla said they  
considered their behavior a bug and would change to match Opera.


> The description of the title element in the spec ("4.2.2 The title  
> element") says:
>
>     Contexts in which this element may be used:
>         In a head element containing no other title elements.
>
> I don't care very strongly about whether or not title elements are  
> allowed anywhere, but I do think the output of the parsing algorithm  
> should be valid html according to the rest of the spec.

Why?


> I think everything I've said about the <title> element also applies to  
> the <base> element.
>
>
> FWIW: In our implementation, I've changed the handling of "base" and  
> "title" in "in body" to:
>
>     Process the token using the rules for the "after head" insertion  
> mode.
>
> instead of processing them with the rules for "in head".

This doesn't result in "valid HTML" when there are multiple <title>s or  
<base>s or when the <base> doesn't have "either an href attribute, a  
target attribute, or both" or where the <base> element's href doesn't  
"contain a valid URL" or when the element doesn't "come before any other  
elements in the tree that have attributes defined as taking URLs", and so  
forth.

http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-base-element

Not to mention cases where the notion of "valid HTML" depends on external  
resources or the author's intent (e.g. <img>).

-- 
Simon Pieters
Opera Software

Received on Monday, 10 November 2008 04:59:30 UTC