DOM Tree
Description
Any HTML document can be represented as a hierarchy of nodes using the DOM.
There are several node types, each representing different information and/or markup in the document.
Example
For instance, consider the following HTML:
<html>
<head>
<title>Sample Page</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
The DOM tree for the code above.
Document
|
+--Element html
|
+--Element head
| |
| +--Element title
| |
| +--Text Sample Page
+--Element body
|
+--Element p
|
+--Text Hello World!
Note
A document node represents every document as the root. The document element is the outermost element in the document. There can be only one document element per document.
In HTML pages, the document element is always the html
element.