Profile Photo

what is DOM ( Document Object Model )

Created on: Aug 2, 2024

The Document Object Model (DOM) is a programming interface for web documents. It represents the structure of a document as a tree of nodes, where each node represents a part of the document (such as an element, attribute, or piece of text).

For example, consider below html document,

<!DOCTYPE html> <html> <head> <title>Example Page</title> </head> <body> <h1>Hello, World!</h1> <p>This is a paragraph.</p> </body> </html>

this can be represented as DOM tree as below

- Document - html - head - title ("Example Page") - body - h1 ("Hello, World!") - p ("This is a paragraph.")