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 between

  • document.body Returns <body> element
  • document.documentElement Returns <html> element

See also:

Document body attribute

HTML DOM HTML objekt

HTML <html>-etikett

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 DOM Level 1 (1998) feature.

All web browsers support it:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Stöd 9-11 Stöd Stöd Stöd Stöd