document.documentElement returns a document's root element (in no-quirks mode, that is). Thus, in a HTML document, it returns its <html> element (even if the document does not have an explicit <html> element). <!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<title>document.documentElement</title>
<script type="text/JavaScript">
function main() { try {
var rootElement = document.documentElement;
var table = document.getElementById('table');
var rows = table.rows;
for (var r=0; r<rows.length; r++) {
var cells = rows[r].cells;
var key = cells[0].innerHTML;
cells[0].innerHTML = key + ':';
cells[1].innerHTML = rootElement[key];
}
} catch(e) {alert (e);}
}
</script>
</head>
<body onload='main();'>
<code>document.documentElement</code> gets the root element.
<table id='table'>
<tr><td>tagName</td><td></td></tr>
<tr><td>nodeName</td><td></td></tr>
<tr><td>localName</td><td></td></tr>
</table>
</body>
</html>
document object. document.body returns the <body> element. :root. <svg> is the root element of an SVG document.