Stop 01 · How the Web WorksTopics · 6/10

How Browsers Render a Page

Part of the Web Development Roadmap

In short

Your HTML file is just text. The browser turns it into pixels through a fixed set of steps, and knowing those steps is how you make pages feel fast instead of janky.

The browser reads HTML into the DOM, reads CSS into style rules, combines them to work out layout, and then paints pixels on the screen. JavaScript can change any of these steps.

The jaadu builder holds a blueprint and paints a half-finished house.

Think of it like this

Building a house from a blueprint

HTML is the floor plan and CSS is the interior design sheet. The browser first works out what goes where (layout), then paints the walls (paint), then stacks the finished floors together (composite).

Watch it happen

From HTML file to pixels

DOM
CSSOM
Render tree
Layout
Paint
Composite

1/6The browser reads your HTML and builds the DOM, a tree of every element.

The big ideas

What you need to know

HTML becomes the DOM

The browser reads your HTML top to bottom and builds a tree of elements called the DOM.

CSS becomes the CSSOM

Styles are parsed into their own tree. The browser needs both trees before it can draw anything.

Layout, then paint

Layout works out the size and position of every box. Paint fills in colours, text and images.

Some files block the page

CSS in the head and scripts without defer make the browser wait, so the first paint shows up later.

See it in code

Walk through the code

html
1<head>2  <!-- CSS blocks rendering, so keep it small -->3  <link rel="stylesheet" href="styles.css" />4 5  <!-- defer: download now, run after the HTML is parsed -->6  <script src="app.js" defer></script>7</head>

1/2This stylesheet blocks rendering: the browser waits for it before drawing anything.

Without defer, the browser stops building the page to download and run app.js. With defer, the page keeps rendering while the script downloads.

Save yourself the pain

Common mistakes

Oops

Putting big script tags in the head without defer or async.

Do this instead

Add defer (or move scripts to the end of body) so the browser can show content first.

Oops

Animating width, height or top, which redoes layout on every frame.

Do this instead

Animate transform and opacity instead. They skip layout and paint, so animations stay smooth.

Your mission

Watch the pipeline live

~15 min

Quick check

Which of these animations is the smoothest for the browser?

Go deeper

  1. 1Record a page load in the DevTools Performance tab and find the layout and paint steps.
  2. 2Learn why a large script tag in the head can delay the whole page from showing.
  3. 3Compare viewing the page source with the Elements tab to see the live DOM.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge