HTML DOM Document documentElement attribute
- Previous Page doctype
- Next Page documentMode
- Go to the Previous Level HTML DOM Documents
Definition and usage
documentElement
The property returns the document's element (as an Element object).
documentElement
It is read-only.
For HTML documents, the object returned is the <html> element.
Hint
document.body
and document.documentElement
The difference is:
document.body
Returns the <body> elementdocument.documentElement
Returns the <html> element
See also:
Example
Get the name of the document element node:
document.documentElement.nodeName;
Syntax
document.documentElement
Return value
Type | Description |
---|---|
Object | Document's Element object. |
Browser support
document.documentElement()
It is a feature of DOM Level 1 (1998).
All browsers support it:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | 9-11 | Support | Support | Support | Support |
- Previous Page doctype
- Next Page documentMode
- Go to the Previous Level HTML DOM Documents