Skip to main content

Command Palette

Search for a command to run...

Under the Hood: How a Web Browser Turns Code into Websites

Published
3 min read

What a browser actually is (beyond “it opens websites”)

A browser is not just a website opener.

Browser is a software that:

  • talks to servers

  • downloads data

  • understands HTML, CSS, JavaScript

  • shows content on screen

When you type a URL and press Enter:
👉 a lot of things happen in background

Browser acts like a middleman between user and internet.

Main parts of a browser (high-level overview)

A browser is made of many parts.

At high level, browser has:

  • User Interface

  • Browser Engine

  • Rendering Engine

  • Networking

  • JavaScript Engine

All these parts work together to display a web page.

User Interface: address bar, tabs, buttons

This is the part user can see and touch.

User Interface includes:

  • Address bar

  • Back / Forward buttons

  • Refresh button

  • Tabs

  • Menu

UI does not load website.
UI only takes input from user and shows output.

Browser Engine vs Rendering Engine (simple distinction)

Browser Engine

Browser engine:

  • controls whole browser

  • connects UI with rendering engine

  • manages actions like reload, navigation

Rendering Engine

Rendering engine:

  • reads HTML

  • reads CSS

  • creates page layout

  • paints pixels on screen

Example:

  • Chrome → Blink

  • Firefox → Gecko

In simple words:
👉 Browser engine manages
👉 Rendering engine displays

Networking: how a browser fetches HTML, CSS, JS

Browser uses networking layer to talk to servers.

Steps:

  • Browser sends HTTP request

  • Server sends response

  • Browser receives files

Files received:

  • HTML file

  • CSS files

  • JavaScript files

  • Images

Without networking:
👉 browser cannot load web pages

HTML parsing and DOM creation

HTML file is just text.

Browser:

  • reads HTML line by line

  • understands tags

  • creates a tree structure

This tree is called DOM (Document Object Model).

Example:

<html>
  <body>
    <h1>Hello</h1>
  </body>
</html>

Converted into:
👉 DOM tree

CSS parsing and CSSOM creation

CSS is also text.

Browser:

  • reads CSS rules

  • understands styles

  • creates another tree

This tree is called CSSOM.

CSSOM tells:

  • color

  • size

  • position

  • fonts

How DOM and CSSOM come together

DOM says:
👉 what elements exist

CSSOM says:
👉 how elements look

Browser combines:

DOM + CSSOM → Render Tree

Render Tree contains only visible elements.

Layout (reflow), painting, and display

Layout (Reflow)

Browser calculates:

  • width

  • height

  • position of elements

Painting

Browser fills:

  • colors

  • borders

  • text

  • images

Display

Final pixels are shown on screen.

This happens very fast.

Very basic idea of parsing (simple math example)

Parsing means:
👉 converting text into meaning

Example:

2 + 3 * 4

Computer:

  • reads numbers

  • understands operators

  • follows rules

  • calculates result

Same way:

  • browser reads HTML

  • understands structure

  • creates DOM

Simple summary

Browser:

  • fetches data

  • understands code

  • builds structure

  • applies styles

  • shows page

So browser is:
👉 interpreter + renderer + network tool

Not just a website opener.