Document Object Model (DOM)

Document Object Model (DOM) is a cross-platform and language-independent interface that treats an XML or HTML document as a tree structure wherein each node is an object representing a part of the document.

What is Document Object Model?

The Document Object Model (DOM) is a programming interface for HTML and XML documents. It represents the document as a tree-like structure of objects that can be manipulated with JavaScript or other programming languages.

The DOM provides a way to access and manipulate the content and structure of an HTML or XML document. It allows developers to dynamically change the content, structure, and style of a document in response to user events or other changes. The DOM tree is hierarchical, with each element represented as a node in the tree. The top-level node of the tree is the Document node, which represents the entire HTML or XML document. Below the Document node are the Element nodes, which represent the HTML or XML elements, such as p>, div>, or table>. The Element nodes can have child nodes, such as other elements, text nodes, or attributes.

By manipulating the DOM tree, developers can create dynamic web pages, perform client-side validation, and enhance user interactions. For example, JavaScript can be used to add, remove, or modify elements and attributes of the DOM, respond to user input, and dynamically update the content of the web page.

Snippet from Wikipedia: Document Object Model

The Document Object Model (DOM) is a cross-platform and language-independent interface that treats an HTML or XML document as a tree structure wherein each node is an object representing a part of the document. The DOM represents a document with a logical tree. Each branch of the tree ends in a node, and each node contains objects. DOM methods allow programmatic access to the tree; with them one can change the structure, style or content of a document. Nodes can have event handlers (also known as event listeners) attached to them. Once an event is triggered, the event handlers get executed.

The principal standardization of the DOM was handled by the World Wide Web Consortium (W3C), which last developed a recommendation in 2004. WHATWG took over the development of the standard, publishing it as a living document. The W3C now publishes stable snapshots of the WHATWG standard.

In HTML DOM (Document Object Model), every element is a node:

  • A document is a document node.
  • All HTML elements are element nodes.
  • All HTML attributes are attribute nodes.
  • Text inserted into HTML elements are text nodes.
  • Comments are comment nodes.
  • kb/document_object_model.txt
  • Last modified: 2023/03/25 20:05
  • by Henrik Yllemo