[whatwg] Handling <title> inside <body>

Ian Hickson ian at hixie.ch
Mon Dec 1 19:53:53 PST 2008


On Tue, 11 Nov 2008, Tommy Thorsen wrote:
>
> I just came across another related problem. Consider the following 
> markup:
> 
> <!doctype html><select><title>TITLE</title></select>
> 
> My version of Firefox moves the title to head, Opera ignores the title 
> completely, and the html 5 parsing algorithm produces the following 
> peculiar markup:
> 
> <!DOCTYPE html>
> <html>
>    <head></head>
>    <body>
>        <select>TITLE</select>
>    </body>
> </html>
> 
> Should this title be allowed or ignored? Right now we ignore the start 
> and end tags, but insert the CDATA into the select element. I'm tempted 
> to ignore CDATA unless the current node is an option element in the "in 
> select" insertion mode.

What HTML5 does here is compatible with what IE8 does, so I'd rather stick 
with that.


> Since we were discussing scripts creating unexpected DOMs, I had to try 
> the following:
> 
> <!doctype html>
> <script>
>    function button_onclick() {
>        document.getElementById('myselect').innerHTML = '<title>TITLE</title>';
>        alert('title inserted');
>    }
> </script>
> <select id="myselect"></select>
> <input type="button" value="Make Title" onclick="button_onclick();" />
> 
> On Firefox, the title is inserted into the select element, but does not 
> actually work. Opera seems to prevent the title element from being 
> inserted into the select element altogether.

Per HTML5, this wouldn't actually put a <title> element in the <select> 
(it's the same as the original example). You should test it with 
document.createElement and select.appendChild.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list