DOM Document.documentElement Property
The documentElement property returns the root element of the page, the html element.
Description
The read-only documentElement property returns the document's root element, the <html> element in a web page. It's where you set page-wide attributes such as lang, theme classes or data-theme, and where you set CSS custom properties that apply everywhere (it matches the :root selector).
It's also the element to measure for page-wide dimensions: document.documentElement.clientWidth gives the viewport width without scroll bars, and scrollHeight gives the full height of the page.
Setting the lang attribute on it, document.documentElement.lang = 'fr', tells screen readers and translation tools which language the page is in, which is important when a single-page application switches languages.
Syntax
document.documentElementValue
The root element of the document, <html> for HTML pages.
Example
Browser Support
The following information will show you the current browser support for the Document.documentElement property. Hover over a browser icon to see the version that first introduced support for this property.
Desktop





Tablets & Mobile





