Back to HTML

What HTML Is and How a Browser Reads It

Coding Tutorials Team 1 August 2026

Almost every early problem with HTML comes from a single misunderstanding: people assume the browser displays their file. It does not. The browser reads the file, builds a completely separate structure in memory from it, and then displays that structure. Once you know this, a whole category of confusing behaviour stops being mysterious.

HTML describes meaning, not appearance

HTML is a markup language. It has no variables, no loops and no logic. Its entire job is to take content and label what each piece of it is. A heading is labelled as a heading, a paragraph as a paragraph, a list as a list. That is the whole idea.

What it deliberately does not do is decide how any of that looks. The fact that a level one heading appears large and bold is not something your markup requested. It is a default style the browser applies because you did not tell it otherwise, and the moment you write any CSS those defaults can disappear entirely. Treating HTML as a way to make text big is the habit that produces markup nobody can maintain.

What the browser actually does with your file

When a browser receives your file it runs through roughly these steps:

  • It reads the raw bytes and works out the character encoding, which is why the charset declaration matters.
  • It splits the stream into tokens: start tags, end tags, text, comments.
  • It turns those tokens into a tree of nodes, where each element becomes an object with a parent and children.
  • It applies styles to that tree, works out the geometry of every box, and paints the result.

That tree is the Document Object Model, usually shortened to the DOM. It is the thing your CSS targets and the thing JavaScript manipulates. Your file is only the instructions used to build it.

Why the DOM is not always what you wrote

This is the part that catches people out. The parser is required to produce a valid tree no matter what you feed it, so when your markup breaks the rules it does not stop and complain. It repairs. A paragraph left unclosed gets closed automatically the moment a block element starts. A table row placed outside a table is quietly moved. Elements missing from your file are inserted for you, which is why a document with no body tag still has a body node.

The consequence is that a page can look almost right while the underlying structure is not the one you intended. Then a CSS rule targeting a child selector fails, or a JavaScript query returns nothing, and the file on screen offers no clue why. Inspecting the element panel in your browser tools shows you the DOM, not your source, and the difference between the two is often the answer.

The document is a tree, so think in trees

Every element sits inside exactly one parent and can contain children. That containment is not decoration. It determines which CSS rules inherit down, which elements a selector can reach, what an assistive technology announces and in what order, and how events travel when something is clicked.

Writing markup is therefore closer to designing a structure than to formatting text. Before you type anything, it helps to ask what this content is and what it belongs to. A navigation bar is a list of links inside a navigation region. An article headline belongs to the article, not floating above it. Getting that hierarchy right first makes styling straightforward later, and getting it wrong makes styling a fight you keep almost winning.

Where HTML stops and the rest begins

The three languages of the front end divide cleanly. HTML supplies structure and meaning. CSS decides presentation. JavaScript adds behaviour. Problems appear when one is used to do the job of another, and the classic case is markup written to control layout rather than to describe content.

A useful test for any page you build is to load it with styling disabled. What remains should still read as a sensible document from top to bottom, with headings that outline the content and links that make sense out of context. If it does, your structure is sound and everything else is a styling decision. If it collapses into meaningless fragments, no amount of CSS will fix what is underneath.

What to take away

You are not writing what the user sees. You are writing a description of your content that a browser converts into a tree, and everything else in web development operates on that tree. Learning to picture it while you type is the single habit that separates markup which behaves from markup which merely happens to look correct today.