Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Nodes

HTML DOM Nodes


In the HTML DOM, everything is a node. The DOM is HTML viewed as a tree of nodes.


DOM Nodes

DOM Nodes

According to the W3C HTML DOM standard, everything in an HTML document is a node:


HTML DOM Node Tree

The HTML DOM views an HTML document as a tree structure. This structure is called anode tree:

HTML DOM Tree Example


Node Parents, Children, and Siblings

Nodes in a node tree have hierarchical relationships with each other.

We commonly useparent, childandsiblingand other terms to describe these relationships. A parent node has child nodes. Child nodes at the same level are called siblings (brothers or sisters).

The image below shows a part of the node tree, as well as the relationships between nodes:

Node tree

See the HTML snippet below:

<html> <head> <meta charset="utf-8"> <title>DOM Tutorialtitle> head> <body> <h1>DOM Lesson 1h1> <p>Hello world!p> body> html>

From the HTML above:

And: