XML documents always have one root node that wraps the rest of the document. For HTML documents, the root is the <html> tag. To access the root, use the documentElement property of the document object.
document.documentElement <html> nodeType is 1 (an element node): document.documentElement.nodeType 1
For element nodes, both nodeName and tagName properties contain the name of the tag.
document.documentElement.nodeName "HTML" document.documentElement.tagName "HTML"