document.documentElement
is a DOM1 property and so was specified more than 13 years ago. In my experiments, it's reliable in IE6 onward and in vaguely recent versions (I haven't gone back far) of Firefox, Chrome, Safari, Mobile Safari, Opera, and Konqueror when I use the HTML5 doctype. So that covers a fair range of layout engines: Trident, Gecko, WebKit, Presto, and KHTML.
(It even works if I omit the actual html
tag in my markup [which I'm allowed to do in HTML5 — and apparently even IE6 adds it in for me despite it never having heard of HTML5 — but almost certainly never will in practice].)
Is there any significant browser — Blackberry? Android? — in which I cannot assume document.documentElement
will be present and will refer to the root html
element in an HTML document?