Document Object Model
Subject: Computer and Technology noun /ˈdɑːk.jə.mənt ˈɑːb.dʒɪkt ˈmɑː.dəl/ 1 definition
- web-development
- web-standards
- browser-architecture
- markup-languages
-
Definition (noun)
Entry #91 · UpdatedThe Document Object Model (DOM) is a cross-platform, language-independent application programming interface (API) that represents an HTML, XML, or SVG document as a hierarchical, in-memory tree of interconnected objects called nodes. When a web browser or markup parser loads serialized source text, it constructs this live node tree—representing elements, attributes, text content, and comments—so scripts can traverse parent-child relationships, read or mutate document structure, attach event handlers, and modify styles dynamically. Rather than being the static markup file itself or the final rasterized pixels, the DOM acts as the live programmatic boundary between application scripts and the rendering engine, ensuring structural updates trigger corresponding layout and visual changes.
Common Forms
HTML DOM: Extends core DOM interfaces with HTML-specific element objects, form controls, and forgiving parser behavior tailored to interactive web pages in browsers.
XML DOM: Provides a strict, case-sensitive tree representation for well-formed XML documents with full namespace awareness for data interchange, configuration files, and document parsers.
Shadow DOM: Attaches an encapsulated, isolated node subtree to a host element so Web Components can scope internal markup and CSS rules separately from the surrounding main document tree.
Virtual DOM: Maintains a lightweight, in-memory JavaScript representation of the UI tree within frameworks like React to diff state transitions before committing minimal batched mutations to the live browser DOM.
Example
When a shopper clicks an "Add to Cart" button on an e-commerce product page, a JavaScript event listener calls
document.querySelector("#cart-badge")to locate the header badge node in the DOM tree and updates itstextContentfrom"2"to"3". Observing that node mutation, the browser engine recalculates styles and repaints the updated counter directly in the viewport without re-fetching the HTML document.