This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

documentElement

Summary

Gets the root node of the document.

Property of dom/Documentdom/Document

Syntax

Note: This property is read-only.

var documentElement = document.documentElement;

Return Value

Returns an object of type DOM NodeDOM Node

The root element of the document.

Examples

This example uses the documentElement property to get the innerHTML property of the entire document, essentially everything inside the <html>...</html> tags.

<!doctype html>
<html>
 <head>
  <script>
function getHTML() {
   var sData = document.documentElement.innerHTML;
   document.getElementById("oResults").value = sData;
}
window.addEventListener("load", getHTML, false);
  </script>
 </head>
 <body>
  <textarea id="oResults" cols="50" rows="10"></textarea>
 </body>
</html>

Notes

The root node of a typical HTML document is the html object.

Related specifications

DOM Level 3 Core
Recommendation

Attributions