What HTML Is and How Browsers Read It
HTML is text plus markup that a browser parses into a tree. See what the parser does with sloppy input and why HTML never throws an error.
What HTML Is and How Browsers Read It
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- HTML is plain text with markup. Tags mark which parts of the text are headings, paragraphs, links or images, and the browser decides how to show each part.
- A browser parses HTML into a tree of objects called the DOM. Your CSS and JavaScript work on that tree, not on the text you typed.
- HTML has no syntax errors in the way a programming language does. The parser repairs bad markup by fixed rules, so mistakes show up as a strange tree rather than a crash.
- A missing closing `</p>` is fine, but a `<div>` inside a `<p>` is not: the parser closes the paragraph first, which can leave an empty `<p>` behind.
- Without a doctype the browser renders in quirks mode. In a test, `document.compatMode` was `BackCompat` without one and `CSS1Compat` with `<!doctype html>`.
The problem HTML solves
A server sends your browser a stream of text. The browser has to show a page: headings bigger than body text, links you can click, images in the right place. Plain text can’t say any of that. A line reading “Welcome” could be a title, a button label or a sentence.
HTML solves this by adding markup around the text. <h1>Welcome</h1> says: this text is the top-level heading. The tags don’t say how big or what colour. They say what the text is, and the browser applies its own defaults. CSS later changes the look. That split, meaning in HTML and appearance in CSS, is the first idea in this roadmap.
It is also why HTML is not a programming language. There are no variables, no conditions, no loops. You label content and the browser supplies the behaviour. A <button> is focusable and clickable, and an <a href> follows its link, because the browser already knows what those words mean.
From text to tree
The browser doesn’t render your file directly. It reads the characters, splits them into tokens (start tag, end tag, text, comment) and builds a tree: each element becomes an object, nested inside its parent. That tree is the DOM, the Document Object Model. Think of the file as a recipe in a book and the DOM as the dishes laid out on the counter. CSS and JavaScript work on the dishes.
You can see this in DevTools. The Elements panel doesn’t show your file. It shows the tree, including parts the browser added. The rendering lesson in the frontend roadmap follows the tree through layout and paint, and how CSS works and where it lives covers the stylesheet side.
HTML never throws an error
Most languages stop and complain when you write something invalid. HTML’s parser is specified to keep going, and the HTML Living Standard defines exactly what it does with every mistake. Everyone gets the same result. I fed this markup to headless Chromium 159 and printed what the parser built:
| Input | Resulting DOM |
|---|---|
<p>One<p>Two |
<p>One</p><p>Two</p> |
<table><tr><td>a</table> |
<table><tbody><tr><td>a</td></tr></tbody></table> |
<p>a<div>b</div>c</p> |
<p>a</p><div>b</div>c<p></p> |
<b><i>x</b></i>y |
<b><i>x</i></b>y |
hello (nothing else) |
<html><head></head><body>hello</body></html> |
Read the third row twice. A div can’t sit inside a p, so the parser ends the paragraph early. The stray </p> at the end then produces an empty paragraph. Nothing crashes, but the tree isn’t what you wrote, and a CSS rule such as p { margin: 1rem } now matches an element you never intended. The second row is the same story: tbody appeared from nowhere, so a selector like table > tr will never match.
The practical rule: close your tags and nest them correctly, not because the page will break, but so the tree matches your picture of it. The validation lesson shows tools that report these repairs.
One more parsing switch: the doctype
The first line of a modern page is <!doctype html>. It has one job: to keep the browser out of quirks mode, a set of old layout behaviours kept for pages written in the 1990s. In the same Chromium test, content loaded without a doctype reported document.compatMode as BackCompat, and with the doctype it reported CSS1Compat. The next lesson, anatomy of an HTML document, puts the doctype in context with the rest of the skeleton.
What the video covers
The embed is Kevin Powell’s “HTML & CSS for Absolute Beginners: What is HTML?” (January 2025, about 7.5 minutes), the first content lesson of his free beginner course. YouTube lists five chapters: introduction to HTML (0:00), writing basic text (1:32), using HTML tags (2:46), element structure (4:47) and semantic HTML (6:20). I could not read a transcript, so I describe it only from those chapters and the description. It is a gentle introduction: it does not go into the parser or the DOM. Those, the repair table and the quirks-mode test above are this lesson’s own and were checked in a browser. The deeper link is a 17-minute tour of the roughly 25 elements most pages start with.
Where this fits
This is the base of the roadmap. Everything after it describes either the vocabulary the parser recognises (elements, attributes, semantics) or the tree it produces. Next comes anatomy of an HTML document, the skeleton every page starts with.
Check yourself
Why does a page with an unclosed `<p>` tag still render correctly?
The HTML parser has defined recovery rules. A new `<p>` start tag implicitly closes an open `<p>`, so `<p>One<p>Two` becomes two paragraphs. HTML was designed to tolerate this because early authors wrote it by hand.
You write `<p>a<div>b</div>c</p>` and later find an empty paragraph in the DOM. What happened?
A `div` cannot live inside a `p`, so the parser closed the paragraph when it met the `div`. The trailing `</p>` then had nothing to close and produced an empty `<p>`. The tree was `<p>a</p><div>b</div>c<p></p>`.
What is the DOM, and why does it matter that CSS and JavaScript see it instead of your file?
The DOM is the tree of element, text and comment objects the browser builds from your markup. Selectors and scripts operate on that tree, so what the parser repaired is what they see, including tags you never wrote such as `tbody`.
What does HTML mean by calling itself a markup language rather than a programming language?
It describes what content is, not what to do with it. There are no variables, conditions or loops. The browser supplies the behaviour for each element, which is why a `<button>` or `<a>` works without you writing any logic.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.