[whatwg] document.head

On Sun, 20 Sep 2009 16:15:11 -0400, Joseph Pecoraro <joepeck02 at gmail.com>  

> On Sep 20, 2009, at 3:57 PM, Michael A. Puls II wrote:
>> I think it'd be cool to have to complement document.documentElement and  
>> document.body.
> On Sep 20, 2009, at 4: 00PM, Juriy Zaytsev wrote:
>> Surely better than abominable ? `document.getElementsByTagName 
>> ('head')[0]` :)
> I agree. Unfortunately that is the most popular method I've seen.  There  
> are better solutions, but they haven't caught on.  I think a smarter  
> idea would be to look at the children of the <html> element.  Something  
> like this almost always works:
>    var head = document.documentElement.firstChild

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.

Yet, I still like document.head as it's shorter and it's more direct about  
what you're doing.

I think I remember someone saying that Netscape (the somewhat recent, not  
too old versions) had support for document.head, for a little while at  
least. And, in HTML, head is pretty important.


Received on Sunday, 20 September 2009 14:47:17 UTC