HTML DOM Document documentElement attribute

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> element
  • document.documentElement Returns the <html> element

See also:

Document body attribute

HTML DOM HTML Object

HTML <html> Tag

Example

Get the name of the document element node:

document.documentElement.nodeName;

Try it yourself

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