# Document Object Model (DOM)

> The browser's live tree of a page. JavaScript can read it and change it.

**Field:** Software Development  
**Category:** Web Development  
**Also known as:** DOM, DOM Tree, querySelector

## Think of it like

Think of it like a family tree for a page. Each part has a parent and kids, and code can move them.

## Definition

The DOM is the browser's live copy of a web page, held as a tree of parts. When a page loads, the browser turns the HTML into this tree. JavaScript can then find any part, change its text, add new parts or remove old ones. The page on screen updates to match. Every interactive web page works by changing the DOM.

## Example

When Lucy adds a mug to her cart, JavaScript finds the cart count in the DOM and changes it from 2 to 3.

## Example code

```javascript
document.querySelector("h1").textContent = "Hi Emma";
```

Find the first heading on the page and change its words.

## Why it matters

Every click that changes a page without reloading it goes through the DOM.

## Common mistake

Changing the DOM many times in a loop. Each change can make the browser redraw, so batch them.

## Three principles

- **A tree of parts.** Built from the HTML.
- **Live.** Change it and the page changes.
- **JavaScript's handle.** How code reaches the page.

## Related terms

- [HyperText Markup Language (HTML)](https://learn.benibix.com/term/development/html)
- [JavaScript](https://learn.benibix.com/term/development/javascript)
- [Browser Event](https://learn.benibix.com/term/development/browser-event)
- [Cascading Style Sheets (CSS)](https://learn.benibix.com/term/development/css)
- [Browser DevTools](https://learn.benibix.com/term/development/browser-devtools)
- [Virtual DOM](https://learn.benibix.com/term/development/virtual-dom)

## Told apart from

- [Virtual DOM vs DOM](https://learn.benibix.com/compare/virtual-dom-vs-dom): People think the virtual DOM is a faster DOM that the browser has, and it is not. The DOM is the real page the browser draws. The virtual DOM is a copy a library like React keeps in memory. The library compares two copies and then changes the real DOM as little as it can.
- [HTML vs DOM](https://learn.benibix.com/compare/html-vs-dom): People think the DOM is the HTML file, and it is not. The HTML file is the text the server sends. The DOM is the live tree the browser builds from it. Scripts change the DOM, not the file. So the page on screen can differ from the page source.

## Taught in

- [JavaScript and the DOM](https://learn.benibix.com/learn/development-web/javascript-and-the-dom): HTML, CSS and JS, 12/14

---

Source: https://learn.benibix.com/term/development/dom
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
