W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2008

[whatwg] Handling <title> inside <body>

From: Ian Hickson <ian@hixie.ch>
Date: Tue, 2 Dec 2008 03:53:53 +0000 (UTC)
Message-ID: <Pine.LNX.4.62.0812020351260.17414@hixie.dreamhostps.com>
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.   `._.-(,_..'--(,_..'`-.;.'
Received on Monday, 1 December 2008 19:53:53 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:46 UTC