Skip to the workspace
Pebellslearn by building
HTML Syntax  ›  Lesson

How Browsers Read HTML

Browsers 12 minA browser parses HTML into a tree of elements called the DOM, forgives many mistakes silently, and treats tag and attribute names case-insensitively.

html / How Browsers Read HTML

Explore each scene at your own pace.

01 · The rule

The rule

How Browsers Read HTML

A browser parses HTML into a tree of elements called the DOM, forgives many mistakes silently, and treats tag and attribute names case-insensitively.

Compare written markup with the document tree the browser actually constructs.

A browser is the program that fetches your HTML and turns it into something people can see, hear and click. Chrome, Firefox, Safari and Edge all follow the same HTML standard, so well-written markup looks and behaves consistently across them.

The rule

The browser builds a tree, forgives mistakes, and ignores letter case.

It builds a tree. The browser reads your HTML from top to bottom and builds a tree of objects called the DOM (Document Object Model). Each element becomes a node; nested elements become children:

<body>
  <h1>Trips</h1>
  <p>Next stop: <em>Goa</em></p>
</body>

Here body is the parent of h1 and p, and em is a child of p. CSS styles this tree and JavaScript changes it, so its shape matters.

It forgives mistakes. If you forget a closing tag, the browser does not show an error. It follows standard recovery rules and guesses. Sometimes the guess matches your intention, sometimes it does not, and you only find out when a style or script misbehaves. Forgiving is not the same as correct.

It ignores letter case in names. <P>, <p> and <P CLASS="x"> all mean the same thing, because tag and attribute names are case-insensitive. The modern convention is to write them all in lowercase. Attribute values are a different story: class="Menu" and class="menu" are two different class names.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.