Skip to content
UniCircle
EasyConceptualDOM

HTML vs the DOM

Question JS-DOM-001

What is the DOM, and how is it different from the HTML file the server sends?

Show the explanation

Model answer. HTML is text: the markup the server sends. The browser parses it and builds the DOM (Document Object Model), a live tree of objects in memory, one node per element, text and comment, with document at the root.

Differences that matter:

  • The DOM is what you script: document.querySelector('h1').textContent = 'Hi' changes the page instantly, but the HTML file is untouched.
  • The browser fixes invalid HTML while building the tree (adds missing <tbody>, closes tags), so the DOM may not match the source exactly.
  • JavaScript can add, remove and move nodes, so after a while the DOM can look nothing like the original HTML. "View source" shows the HTML; the Elements panel in DevTools shows the current DOM.

The DOM is also a language-neutral API; JavaScript is just the most common way to use it.

Original UniCircle question. Last reviewed 22 Oct 2026.