Skip to content
BENIBIX Learn

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.

Development🌐 Web Development

HyperText Markup Language (HTML)

The language that sets out what is on a web page, using tags.

HTML is the language that says what is on a web page. It wraps each piece of content in tags, like <h1> for a heading or <a> for a link. The browser reads the tags and shows the page. HTML gives the page its structure, CSS gives it looks and JavaScript makes it act. Every web page starts as HTML.

Example
Emma writes her first page in HTML. It has a heading, a short paragraph and a link to her email.
Why it matters
HTML is the base of the web. Search engines and screen readers rely on it being right.
Full entry
Development🌐 Web Development

Document Object Model (DOM)

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

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.
Why it matters
Every click that changes a page without reloading it goes through the DOM.
Full entry

In one line

HyperText Markup Language (HTML)
The language that sets out what is on a web page, using tags.
Document Object Model (DOM)
The browser's live tree of a page. JavaScript can read it and change it.