Skip to the content
Start free

DOM (Document Object Model)

The DOM (Document Object Model) is the live tree of objects a browser builds from a page’s HTML, which scripts can read and change and which the browser uses to draw what you see. Your HTML file is the recipe. The DOM is the dish as it is right now, after the browser and any JavaScript have worked on it. Search engines and AI tools that render pages read the DOM, not only the file.

What is the DOM, in plain words? #

MDN’s introduction to the DOM calls it a programming interface for web documents that represents the page as nodes and objects, so programs can change its structure, style and content. Each tag becomes a node. Text inside a tag becomes a text node. Nodes sit inside other nodes, like branches on a tree, with the html element at the top, then head and body, then everything else.

MDN also makes 2 points that clear up confusion. The DOM is not a programming language. And it is not part of JavaScript: it is a Web API that JavaScript, and other languages, use to work with the page. The rules for how it behaves are kept by WHATWG in the DOM Living Standard, which is updated over time rather than issued as fixed versions.

How is the DOM different from the HTML source? #

MDN explains that when a browser parses an HTML document, it builds a DOM tree and uses it to display the page. The two often differ:

HTML source (view source) DOM (inspect element)
What the server sent What the browser built from it
Fixed once loaded Changes as scripts run
Missing tags stay missing The browser fills gaps, such as a missing tbody
No content added by JavaScript Includes content scripts inserted

A script can find parts of the tree and change them. For example, document.querySelectorAll("p") returns every paragraph, and a script can then edit, add or remove any of them. That is how menus open, baskets update and reviews load without a full page reload.

Google’s guide to JavaScript SEO basics says Google handles JavaScript pages in 3 phases: crawling, rendering and indexing. After rendering, Google uses the rendered HTML to index the page and looks in it again for links. The rendered HTML is, in effect, the DOM written back out. So:

  • Content added late can still count, but only after rendering, which can come later than the first crawl. Content that is in the first HTML does not have to wait.
  • Links must be real links. The same guide says Google only discovers a link when it is an <a> tag carrying an href. A clickable box with only a script behind it may never be followed. See internal linking.
  • Do not rely on scripts to remove noindex. Google says that when it sees a noindex tag it may skip rendering, so a script that removes it later may never run for Google.
  • Check what Google sees with the URL inspection tool, which shows rendered HTML.

The topic is covered in more depth on our JavaScript SEO page.

Why does it matter for AI answers? #

Many AI crawlers fetch the HTML and read the text in it. Not all of them run JavaScript the way a full browser does. If your price, stock or main answer only appears in the DOM after a script runs, a simple fetcher may see an empty box. Google’s own guidance for AI features lists making important content available in textual form as basic good practice. The safest route for both search and answer engine optimisation is to put key facts in the first HTML, and let scripts add extras on top. Our AI readiness checker and the JavaScript SEO checker help you spot the gap.

Does DOM size matter? #

Yes, for speed. Chrome’s Lighthouse guide to avoiding an excessive DOM size warns when the body has more than about 800 nodes and fails it at more than about 1,400. It explains that the browser must keep working out the position and styling of nodes as people and scripts interact, so a big tree with complex styles can slow rendering and response. That links to Interaction to Next Paint and the other Core Web Vitals. Page builders that wrap every block in several layers of div are a common cause.

A worked example #

A product page’s HTML file has an empty box: <div></div> where reviews go. After load, a script fetches 12 reviews and adds them as 12 new nodes. In the browser, a shopper sees the reviews. Open view source and the box is still empty. Open the inspector and the reviews are there in the DOM. Google may see them after rendering. A simple AI fetcher that does not run scripts will not. If those reviews feed your review snippets through schema markup, put the markup and at least a summary in the first HTML so every reader gets it.

What are the common mistakes? #

  • Checking view source and thinking that is the whole page, or checking the inspector and thinking every bot sees that.
  • Links built with click handlers instead of <a href>.
  • Changing the title tag or canonical tag with a script so the file and the DOM disagree.
  • Hiding the main text until a click. Content behind tabs is fine if it is in the DOM; content fetched only on click may not be seen.
  • Very deep, bloated trees from themes and builders that slow the page.

How do I check it? #

  1. Right-click a page and choose view source. Then right-click and choose inspect. Compare the two for your main text and links.
  2. Use the URL inspection tool in Google Search Console to see Google’s rendered HTML.
  3. Check headings in the page with our heading checker and tags with our meta tag checker.
  4. Run the free HTML formatter on saved source to make a long file easy to read.
  5. Run a Lighthouse report in Chrome to see the DOM size warning, or try our page speed checker (coming soon).

Questions #

Is the DOM the same as HTML? #

No. HTML is the text the server sends. The DOM is the object tree the browser builds from it, which can then change.

What is the shadow DOM? #

It is a hidden sub-tree used by some web components. Google’s JavaScript guide says it flattens shadow DOM and light DOM content when rendering, so content there can be seen if it is in the rendered HTML.

Does CSS change the DOM? #

CSS styles the nodes but does not add or remove them. Hiding something with CSS leaves it in the DOM.

Sources #

Updated 24 November 2026 by URSY.com.

Cite this page: DOM (Document Object Model). URSY. Updated 26 November 2026. https://ursy.com/wiki/dom-document-object-model/ · Section links

Tools for this

All 871 wiki entries, A to Z →