HTML and CSS Reference
In-Depth Information
<h1> <p> <table>
<td> <td>
Figure 15.2 An HTML document as a tree.
The purpose of the hierarchal tree is to provide a logical structure to represent a doc-
ument and a way to navigate that structure, and to add, modify, or delete elements and
content from it. Starting with the document at the top of the tree, called the root , you
can traverse down the tree to every element until you reach the element, attribute, or
text you are seeking. The core DOM identifies each element in the tree as a node object.
There are parent and child nodes, sibling nodes, and more (see Table 15.1).
Table 15.1 Some DOM Objects
The primary data type that represents an HTML element.
The root of the document tree.
An element within an HTML document.
Attributes of an HTML tag.
The text between markup tags, such as the text between <h1>
and </h1>.
15.3 Nodes
Every time you load an HTML page, the Web browser generates an internal representa-
tion of the page as an upside-down tree structure. The DOM views the trees as a set of
nodes where every HTML element shown in Figure 15.3 is a node. In the tree, the top
Search WWH ::

Custom Search