HTML DOM Document documentElement
Example
Get the name of the document element node:
document.documentElement.nodeName;
Try it Yourself »
Description
The documentElement
property returns a document's element (as an Element object).
The documentElement
is read-only.
For HTML documents the returned object is the <html> element.
Note
The difference between document.body and document.documentElement:
document.body returns the <body> element
document.documentElement returns the <html> element.
See Also:
Syntax
document.documentElement
Return Value
Type | Description |
Object | The document's Element Object |
Browser Support
document.documentElement()
is a DOM Level 1 (1998) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |