Skip to main content

Command Palette

Search for a command to run...

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

Published
4 min read
How a Browser Works: A Beginner-Friendly Guide to Browser Internals
D
I’m a Computer Science Engineer focused on backend development, scalable system design, and real-world production deployments. I build and deploy full-stack applications using Node.js, Express, MongoDB, Redis, Docker, and CI/CD pipelines.

What Is a Browser (Beyond “It Opens Websites”)?

A browser is:

A software system that fetches, understands, and displays web content.

It doesn’t just show text.
It acts like a:

  • Downloader

  • Translator

  • Builder

  • Painter

  • Security guard

All at the same time.

You give it:

HTML + CSS + JavaScript

The browser turns that into:

Pixels on your screen

Main Parts of a Browser (High-Level Overview)

https://beehiiv-images-production.s3.amazonaws.com/uploads/asset/file/e525ea1b-f275-45e2-bd83-cb6725583b22/bb4ed1cf-6143-48b5-b9af-60f65d921e68_500x339.png?t=1651893384

https://files.codingninjas.in/article_images/what-is-a-web-browser-2-1635103986.webp

https://www.researchgate.net/publication/4339962/figure/fig1/AS%3A655113832112129%401533202717611/Overall-architecture-of-our-OP-web-browser-Our-web-browser-contains-five-main.png

4

A browser is made of several major components:

  1. User Interface (UI)

  2. Browser Engine

  3. Rendering Engine

  4. Networking Layer

  5. JavaScript Engine

  6. Data Storage

Think of this as a team, where each part has a specific job.


User Interface (UI)

This is everything you directly interact with:

  • Address bar

  • Back / Forward buttons

  • Refresh button

  • Tabs

  • Bookmarks

The UI:

Takes your input
Sends instructions to the browser engine

It does NOT understand HTML or CSS.


⚙️ Browser Engine vs Rendering Engine

Browser Engine

Acts as a manager.

  • Receives commands from UI

  • Tells rendering engine what to load

  • Coordinates networking, JS engine, storage

Rendering Engine

Acts as a builder & painter.

  • Parses HTML

  • Parses CSS

  • Builds structures

  • Calculates layout

  • Paints pixels

Simple Analogy

  • Browser Engine → Project Manager

  • Rendering Engine → Construction Workers


Networking: How Files Are Fetched

When you enter:

https://example.com

The browser:

  1. Finds server IP using DNS

  2. Opens connection

  3. Sends request

  4. Receives response

Response contains:

  • HTML file

  • CSS files

  • JS files

  • Images, fonts, videos

These are downloaded in parallel.

Think of networking as:

A delivery service bringing raw materials.


📄 HTML Parsing & DOM Creation

https://www.w3schools.com/whatis/img_htmltree.gif

https://i.sstatic.net/kBF3j.png

https://upload.wikimedia.org/wikipedia/commons/5/5a/DOM-model.svg

HTML is plain text:

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

Browser converts this text into a DOM tree.

What Is DOM?

Document Object Model

A tree-like representation of the page.

Example Tree:

Document
 └── body
      ├── h1
      │    └── "Hello"
      └── p
           └── "World"

Why Tree?

Because elements are nested.

Parsing means:

➡️ Read characters
➡️ Identify tags
➡️ Create nodes
➡️ Connect parent-child relationships


🎨 CSS Parsing & CSSOM Creation

https://web.dev/static/articles/critical-rendering-path/render-tree-construction/image/dom-cssom-are-combined-8de5805b2061e.png

https://camo.githubusercontent.com/5bb542d7234aabefa57164d9353f9b51f1a23c7c4dba4a867e160f7cb7b91d0b/68747470733a2f2f63646e2e7261776769742e636f6d2f637373747265652f637373747265652f616166333237652f646f63732f6170692d6d61702e737667

https://web.dev/static/articles/critical-rendering-path/constructing-the-object-model/image/dom-tree-827d5511a67a3.png

CSS file:

h1 { color: red; }
p  { font-size: 20px; }

Browser builds CSSOM (CSS Object Model).

Example:

CSSOM
 ├── h1 → color: red
 └── p  → font-size: 20px

CSSOM is also a tree structure.

Why?

Because CSS has inheritance and cascading rules.


DOM + CSSOM → Render Tree

https://web.dev/static/articles/critical-rendering-path/render-tree-construction/image/dom-cssom-are-combined-8de5805b2061e.png

https://miro.medium.com/v2/resize%3Afit%3A1400/0%2A_mUaF4ho09lojJ7D.png

Browser combines:

DOM + CSSOM = Render Tree

Render Tree contains:

  • Only visible elements

  • Each node has style information

Example:

h1 (color:red)
p  (font-size:20px)

Hidden elements like:

display: none;

❌ Not included.


📐 Layout (Reflow)

https://www.webperf.tips/static/6c2b05dff8f3a74701a9189098f00a39/e1697/LayoutThrashing03.png

https://media.gcflearnfree.org/content/5ef2084faaf0ac46dc9c10be_06_23_2020/box_model.png

https://learn.microsoft.com/en-us/windows/win32/direct3d11/images/d3d11-pipeline-stages.jpg

Browser calculates:

  • Width

  • Height

  • Position (x, y)

For every element.

This step answers:

👉 Where should each box appear?

This is also called Reflow.

If you change size, margin, or font:

➡️ Reflow may happen again.


Painting

After layout:

Browser paints pixels:

  • Backgrounds

  • Text

  • Borders

  • Images

Like painting layers on canvas.


Display (Compositing)

Finally:

All painted layers are combined and pushed to the screen.

You see the page 🎉


Very Basic Idea of Parsing (Simple Example)

Parsing means:

👉 Turning text into structure.

Example:

2 + 3 * 4

Parser builds:

     +
    / \
   2   *
      / \
     3   4

Why?

Because multiplication has higher priority.

Similarly:

HTML:

<div><p>Hello</p></div>

Becomes:

div
 └── p
      └── Hello

Parsing = understanding structure, not just reading characters.


Full Flow: From URL to Pixels

https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bot6krwkd555ob2du8x9.png

https://miro.medium.com/1%2Ab3BgflJLLrKABZ5BCXnegw.png

https://miro.medium.com/v2/resize%3Afit%3A2000/1%2AAjwXe0spMClgE9KhBxuB1Q.png

5

Type URL
   ↓
Networking (download files)
   ↓
HTML → DOM
CSS → CSSOM
   ↓
DOM + CSSOM → Render Tree
   ↓
Layout (positions & sizes)
   ↓
Paint
   ↓
Display on Screen

Where JavaScript Fits

  • JS can modify DOM

  • JS can modify CSS

  • JS can block HTML parsing

That’s why:

<script defer>

or

<script async>

is often used.