You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Document Object Model (DOM) is the data representation of the objects that comprise the structure and content of a document on the web.
4
+
5
+
It represents the page so that programs can change the document structure, style, and content.
6
+
7
+
The DOM represents the document as nodes and objects; that way, programming languages can interact with the page.
8
+
9
+
# DOM Tree
10
+
11
+
The DOM tree (Document Object Model tree) is a hierarchical representation of the structure of a web document, such as an HTML or XML page. It reflects how the browser interprets and organizes the page's content into a tree-like data structure.
12
+
13
+
## Key Concepts:
14
+
- DOM stands for Document Object Model.
15
+
- The DOM turns HTML elements into nodes arranged in a tree structure.
16
+
- Each node represents a part of the document (like an element, text, or comment).
17
+
18
+
## Types of Nodes:
19
+
- Element nodes: HTML elements like <body>, <h1>, <p>.
20
+
- Text nodes: The text inside those elements.
21
+
- Attribute nodes: Attributes like class, id, etc. (usually accessed via element nodes).
22
+
- Comment nodes: HTML comments like <!-- comment -->.
23
+
24
+
## Why It Matters:
25
+
The DOM allows JavaScript to interact with and modify the page dynamically.
26
+
For example: document.getElementById("myId") gets a node, and you can change its content or style.
27
+
28
+
## DOM Tree Example
29
+
30
+

31
+
32
+
33
+
### More:
34
+
[DOM - MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction)
0 commit comments