HTML DOM Document documentElement

Example

Get the name of the document element node:

document.documentElement.nodeName;
Try it Yourself »

Description

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:

The Document body Property

HTML DOM HTML Object

The HTML <html> tag


Syntax

document.documentElement

Return Value

Type Description
ObjectThe document's Element Object

Browser Support

document.documentElement() is a DOM Level 1 (1998) feature.

It is fully supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes 9-11


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.