HTML and CSS Reference
Table 15.2 Node Properties (continued)
What It Does
Returns the name of the node.
Returns the type of the node as a number: 1 for element, 2 for attribute, 3 for text.
Sets the value of the node in plain text.
Returns the root node of the document that contains the node.
Returns the element that contains the current node.
Returns the previous child node of an element at the same level as the current child
Table 15.3 Node Methods
What It Does
Appends a new node onto the end of the list of child nodes.
Makes a clone of a node.
Returns true if the node has children.
insertBefore(new node, current node)
Inserts a new node in the list of children.
Removes a child node from a list of children.
replaceChild(new child, old child)
Replaces an old child node with a new one.
When looking at the structure of the tree hierarchy, some nodes are above others. A node
above another node is a parent node, and the ones below the parent node are its chil-
dren. See Figure 15.4. Any HTML tags that have both an opening and a closing tag are
always parent nodes, for example, <p> and </p> .
Attributes of an element are considered to be separate nodes in their own right. For
example, the href attribute of the <a> tag is an attribute node, not a child of the <a> tag,
and the title attribute of the <p> tag is also an attribute node. The other type of node is
a text node, which represents the text of an element or an attribute, such as <a
href=“http//w3schools.com” , where the quoted string of text (URL) is a text node.