[whatwg] document.head

Hallvord R M Steen hallvors at gmail.com
Tue Oct 6 07:02:58 PDT 2009

2009/9/21 Garrett Smith <dhtmlkitchen at gmail.com>:

>> It wasn't very long ago though that in Opera for example, head wasn't
>> guaranteed to be the first child of the documentElement. But, that'll work
>> now and is pretty good.

> The documentElement.firstChild cannot be expected to be head. It could
> be a text node. For example:-
> <html>
>   <head>
> ...
> the first child node of HTML looks like a textNode with the value
> "\n\n\u0020\u0020".

You might think so. However, as Michael stated above Opera used to do
this, and it broke a number of websites that expected
documentElement.firstChild to be <HEAD> no matter what the actual
markup looked like. So we had to implement a somewhat magic firstChild
on documentElement and I expect other browsers had to too (as your
testing seems to confirm, more or less). Which reminds me, this
peculiarity should possibly be documented in HTML5 :-) .
Hallvord R. M. Steen

More information about the whatwg mailing list