Back to Blog
5 min readBy Tanish Bhandari

How a Browser Works: A Beginner-Friendly Guide to Browser Internals


How a Browser Works: A Beginner-Friendly Guide to Browser Internals

I remember the first time I opened Chrome's DevTools. I was trying to figure out why a button wasn't working, and suddenly I was staring at a tree of HTML nodes, a cascade of CSS rules, and a console spitting out JavaScript errors. It felt like I'd accidentally opened the hood of a car I didn't know how to drive.

But here's the thing — browsers aren't as mysterious as they seem. Once you understand the basic flow, everything clicks.

The Browser Is Not One Thing

Most people think of a browser as a single program. It's not. It's more like a team of specialists, each handling a specific job.

ComponentWhat It Does
User InterfaceThe address bar, tabs, bookmarks, back button — everything you click
Browser EngineThe coordinator that tells other parts what to do
Rendering EngineTakes code and turns it into actual pixels on your screen
NetworkingHandles all the fetching — making requests, receiving files
JavaScript EngineRuns the scripts that make pages interactive

Chrome uses Blink for rendering and V8 for JavaScript. Firefox uses Gecko. Safari uses WebKit. The names are different, but the jobs are the same.

The Journey: From URL to Pixels

When you type a URL and press Enter, a lot happens in a very short time. Let me walk through it.

Step 1: Finding the Server

First, the browser needs to figure out where the website actually lives. You typed google.com, but computers don't understand domain names. They need IP addresses.

So the browser asks DNS — the internet's phonebook — to translate google.com into something like 142.250.193.206. Once it has the address, it opens a TCP connection and sends an HTTP request asking for the page.

A few milliseconds later, the server responds with HTML, CSS, and JavaScript files. Now the real work begins.

Step 2: Parsing HTML into the DOM

The browser reads the HTML file character by character, line by line. As it goes, it builds a structure called the DOM — the Document Object Model. Think of it as a family tree for HTML elements.

<html>
  <body>
    <h1>Hello</h1>
    <p>World</p>
  </body>
</html>

This becomes:

html
 └── body
      ├── h1 → "Hello"
      └── p  → "World"

Every tag becomes a node. Every node knows its parent and children. This tree structure is how the browser understands what's on the page.

Step 3: Parsing CSS into the CSSOM

While the DOM is being built, the browser also parses CSS files and builds another tree — the CSSOM (CSS Object Model). This tree contains all the styling rules.

h1 { color: blue; font-size: 32px; }
p { color: gray; }

Now the browser knows what exists (DOM) and how it should look (CSSOM).

Step 4: Combining into the Render Tree

The browser takes the DOM and CSSOM and merges them into something called the Render Tree. This tree only includes elements that will actually appear on screen.

That means if you have an element with display: none, it doesn't make it into the render tree. Same for <head> content. Only visible stuff gets included, along with its computed styles.

Step 5: Layout (Reflow)

Now the browser needs to figure out geometry. Where does each element go? How big is it?

The layout phase calculates exact positions and dimensions. "This heading is 200 pixels wide, starts at position (10, 50), and is 40 pixels tall."

This process is also called reflow, and it can be expensive. Changing an element's size might force the browser to recalculate the layout of everything around it.

Step 6: Painting

Finally, the browser paints actual pixels. Colors fill in. Text renders. Borders appear. Shadows get drawn.

This is the moment your screen actually shows something. Everything before this was preparation.

What Is Parsing, Really?

Parsing sounds technical, but you do it naturally. When you read the sentence "The cat sat on the mat," your brain breaks it into pieces: subject (cat), action (sat), location (mat).

Browsers do the same thing with code. They tokenize — breaking characters into meaningful chunks. Then they structure — organizing chunks into trees. Then they execute — using those trees to render pages.

The Full Flow

URL entered
    ↓
DNS lookup → IP address
    ↓
TCP connection → HTTP request
    ↓
HTML received → DOM built
    ↓
CSS received → CSSOM built
    ↓
DOM + CSSOM → Render Tree
    ↓
Layout → Calculate positions
    ↓
Paint → Draw pixels
    ↓
Page appears 🎉

Why This Matters

You don't need to memorize every detail. But understanding this flow helps in practical ways.

When a page loads slowly, you can ask: Is it stuck in DNS? Is the server slow? Is there too much JavaScript blocking rendering?

When your CSS isn't applying, you can check: Is this element even in the render tree? Is another rule overriding it?

When animations feel janky, you can investigate: Am I causing constant reflows by changing layout properties?

The browser isn't a black box. It's a pipeline. And once you see the pipeline, debugging becomes a lot less frustrating.



Written by Tanish Bhandari