HTML DOM Document documentElement
Example
Get the name of the document element node:
document.documentElement.nodeName;
Try it Yourself »
Definition and Usage
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 | IE | Edge | Firefox | Safari | Opera |
Yes | 9-11 | Yes | Yes | Yes | Yes |