May 09, 2021 HTML DOM
In HTML DOM, everything is a node. DoM is HTML that is considered a node tree.
According to the HTML DOM standard of W3C, everything in an HTML document is a node:
HTML DOM treats HTML documents as tree structures. This structure is called the node tree:
Nodes in the node tree have hierarchical relationships with each other.
Terms such as parent, child, and sibling are used to describe these relationships. T he parent node has a child node. Children of siblings are called siblings (brothers or sisters).
The following image shows part of the node tree and the relationships between the nodes:
Take a look at the HTML fragment below:
<html>
<head>
<title>DOM Tutorial</title>
</head>
<body>
<h1>DOM Lesson one</h1>
<p>Hello world!</p>
</body>
</html>
As can be seen from the HTML fragment above:
And:
And:
A common error in DOM processing is that you want the element node to contain text.
In this example, the element node, the dom tutorial, contains a text node with the value "DOM tutorial".
The value of the text node can be accessed through the node's innerHTML property.
You'll learn more about innerHTML properties in a later section.