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 returned object is the <html> element.

Hint

document.body And document.documentElement Difference:

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

See also:

Document body attribute

Όνειρο του HTML DOM HTML

HTML <html> Σήμα

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 browsers support it:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Υποστήριξη 9-11 Υποστήριξη Υποστήριξη Υποστήριξη Υποστήριξη