HTML DOM Nodes | Tutorial
Tutorial -- Learning is not just about technology, but also about dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
HTML DOM Tutorial
HTML DOM Tutorial HTML DOM Introduction HTML DOM Nodes HTML DOM Methods HTML DOM Properties HTML DOM Access HTML DOM Modify HTML DOM Modify HTML Content HTML DOM Elements HTML DOM Events HTML DOM Navigation HTML DOM Summary DOM Examples
DOM Reference
HTML DOM Nodes
In the HTML DOM, everything is a node. The DOM is an HTML document viewed as a node tree.
DOM Nodes
According to the W3C HTML DOM standard, everything in an HTML document is a node:
- The entire document is a document node
- Every HTML element is an element node
- The text inside HTML elements is text nodes
- Every HTML attribute is an attribute node
- Comments are comment nodes
HTML DOM Node Tree
The HTML DOM views an HTML document as a tree structure. This structure is called a node tree:
HTML DOM Tree Example
Node Parent, Child, and Siblings
Nodes in the node tree have a hierarchical relationship to each other.
The terms parent, child, and sibling are used to describe these relationships. A parent node has child nodes. Child nodes on the same level are called siblings (brothers or sisters).
- In the node tree, the top node is called the root (root).
- Every node has a parent, except the root (it has no parent).
- A node can have any number of children.
- Siblings are nodes that share the same parent.
The image below shows a part of the node tree, and the relationships between nodes:
Please look at the following HTML fragment:
DOM Lesson 1
Hello world!
From the HTML above:
- The
<html>node has no parent; it is the root node - The parent of
<head>and<body>is the<html>node - The parent of the text node "Hello world!" is the
<p>node
And:
- The
<html>node has two children:<head>and<body> - The
<head>node has two children: the<meta>and<title>nodes - The
<title>node also has one child: the text node "DOM Tutorial" - The
<h1>and<p>nodes are siblings, and they are also children of<body>
And:
- The
<head>element is the first child of the<html>element - The
<body>element is the last child of the<html>element - The
<h1>element is the first child of the<body>element - The
<p>element is the last child of the<body>element
Warning!
A common error in DOM processing is to expect element nodes to contain text.
In this example: <title>DOM Tutorial</title>, the element node <title>, contains a text node with the value "DOM Tutorial".
The value of the text node can be accessed by the node's innerHTML property.
You will learn more about the innerHTML property in a later chapter.
Click to Share Notes
Write notes...
Image URL
Image Description
Share Notes
- Nickname Nickname (Required)
- Email Email (Required)
- Reference URL Reference URL
Category Navigation
- Python / Data Science
- AI / Intelligent Development
- Front-end Development
- HTML Tutorial
- HTML5 Tutorial
- CSS Tutorial
- CSS3 Tutorial
- JavaScript Tutorial
- HTML DOM Tutorial
- TypeScript Tutorial
- AJAX Tutorial
- JSON Tutorial
- Tailwind CSS Tutorial
- Bootstrap4 Tutorial
- Bootstrap5 Tutorial
- Foundation Tutorial
- Vue.js Tutorial
- Vue3 Tutorial
- React Tutorial
- Next.js Tutorial
- AngularJS Tutorial
- Angular Tutorial
- jQuery Tutorial
- jQuery UI Tutorial
- jQuery EasyUI Tutorial
- ECharts Tutorial
- Chart.js Tutorial
- Highcharts Tutorial
- Google Maps Tutorial
- SVG Tutorial
- Font Awesome Tutorial
- Back-end Development
YouTip