Skip to main content

Command Palette

Search for a command to run...

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

Learn How Internet Browsers Function: An Easy Introduction to Browser Basics

Updated
8 min read
How a Browser Works: A Beginner Friendly Guide to Browser Internals

What Really Happens Inside a Browser When You Open a Website?

Most people think a browser is just an app that opens websites. But in reality it is very complex, it is like a separate operating system, it is very different what we think. When we type a URL, press Enter and a page appears, it seems like magically the website landing page appears but behind the scenes, there are a lot of things going on in a specific order.
In this blog we will understand the complete behind the scene process, it is very important because every web developer works with the browser, whether they write HTML, CSS or JS.

Now let’s answer one simple question:

What happens after when we type a URL and press Enter?

A Browser Is Not One Thing

A browser is not a single program doing everything.

It is a collection of components, each with a clear job.

You can think of it like a small factory:

  • One part talks to the internet

  • One part reads HTML

  • One part understands CSS

  • One part draws pixels on your screen

All of them work together to show a webpage.

At a very high level, a browser has:

  • A user interface (address bar, tabs, buttons) - Handles visible elements like the address bar, tabs, back/forward buttons, bookmarks, and menus. It provides the interactive shell for user input and navigation, it is directly connected with browser’s backend.

  • A Browser Engine (Gecko - Used by Firefox , Blink - Used by Google Chrome, Webkit - Used by Apple) - Acts as a coordinator or bridge between the user interface and other core components, such as the rendering and user interface and javascript engine.

  • A networking layer (to fetch files) - Manages HTTP requests to fetch resources like HTML, CSS, images, and scripts from servers.

  • A rendering engine (to turn code into visuals) - Parses HTML/CSS into the DOM and CSSOM, builds the render tree, performs layout (calculating positions), and paints pixels to the screen.

  • A JavaScript engine (to run JS) - Compiles and executes JavaScript code, enabling dynamic interactions by manipulating the DOM. Examples: V8 (Chrome), SpiderMonkey (Firefox).

  • Internal data structures (DOM, CSSOM) - Core models like the DOM (Document Object Model) for HTML structure and CSSOM (CSS Object Model) for styles, used by rendering and JS engines for processing.

Each part has one responsibility.


The User Interface: Where Everything Starts

The user interface is the visible part of the browser.

This includes:

  • Address bar

  • Back and forward buttons

  • Tabs

  • Reload button

When you type a URL and press Enter, the UI does not load the website itself. User interface is usually connected with backend, that give functionality to the buttons.

It simply passes the URL to the browser’s internal systems and says: Go get whatever lives at this address.


Browser Engine vs Rendering Engine (simple distinction)

The browser engine acts like a coordinator or manager. It sits between the user interface and the rest of the browser. When we type a URL, click refresh, open a new tab, or press the back button, the browser engine decides what should happen next.
It tells the networking part to fetch data, tells the rendering engine to update the page, and keeps everything moving in the correct order. It does not draw anything on the screen by itself. Its main job is coordination and control.

  • The boss / coordinator

  • Controls the whole page loading process

  • Connects UI ↔ rendering ↔ JavaScript

  • Decides when things happen

Overall, keep one thing in mind that browser engine is like a manger, who coordinated between different process.

The rendering engine, on the other hand, focuses only on turning code into visuals. It takes HTML and CSS, builds internal structures, calculates layout, paints pixels, and prepares the page for display. Whenever you see text, colors, boxes, or images on a webpage, that work is done by the rendering engine.

  • The worker

  • Reads HTML + CSS

  • Calculates layout

  • Draws pixels on the screen

Overall, thing render engine is like a painter, who paints the whole page UI.


Networking: How a Browser Fetches HTML, CSS, and JavaScript

When we press Enter after typing a URL, the browser first needs to find where the website lives. Computers do not understand website names, so the browser must convert the domain name into an IP address. This is done using DNS.

The browser first checks its cache to see if it already knows the IP address. If not, it asks a DNS resolver. The resolver then follows a fixed path: it asks the root DNS server, then the TLD server (like .com or .app), and finally the authoritative DNS server. The authoritative DNS returns the correct IP address, which is sent back to the browser and saved in cache.

Once the browser has the IP address, it creates a connection with the server using TCP. If the site uses HTTPS, a secure connection is also established. After the connection is ready, the browser sends a request asking for the webpage.

The server responds with the HTML file. While reading the HTML, the browser finds links to CSS, JavaScript, images, and fonts, and sends more requests to fetch them. When all required files arrive, networking is done and the browser moves on to parsing and rendering the page.


HTML Parsing: Turning Text into Structure

HTML arrives as plain text.

The browser cannot use text directly to draw a page.

So it parses the HTML.

Parsing simply means: Reading something step by step and understanding its meaning.

While reading HTML, the browser builds a structure called the DOM (Document Object Model).

You can imagine the DOM as a tree:

  • <html> is the root

  • <body> is a branch

  • Headings, paragraphs, links are smaller branches

This DOM represents what elements exist on the page, not how they look.


CSS Parsing: Understanding Styles

CSS is also plain text when downloaded.

The browser parses CSS separately and builds another structure called the CSSOM.

The CSSOM answers questions like:

  • What color is this text?

  • How wide is this box?

  • Where should this element be positioned?

So now the browser has:

  • DOM → what exists

  • CSSOM → how it should look


DOM + CSSOM: Creating the Render Tree

The browser now combines DOM and CSSOM.

The result is the Render Tree.

The Render Tree:

  • Includes only visible elements

  • Contains layout and style information

  • Is ready to be drawn on screen

Hidden elements like display: none are excluded here**.**


Layout, Painting, and Display

Once the Render Tree is ready, the browser moves through three final steps:

Layout (Reflow)

The browser calculates:

  • Exact position of each element

  • Exact size of each element

Painting

The browser fills pixels:

  • Colors

  • Text

  • Images

  • Borders

Display (Compositing)

Everything is combined and sent to your screen.

At this point, you finally see the webpage.


A Very Simple Parsing Example

Parsing simply means breaking something into parts and understanding its structure.

Take this expression: 1 + 2 * 3.

At first glance, it looks like a single line of text. But to evaluate it correctly, we cannot read it from left to right blindly.

A parser first looks at the expression and understands the rules. It knows that multiplication has higher priority than addition. So instead of adding first, it groups 2 * 3 together.

The parser then converts this expression into a tree. At the top is the + operator. On one side is 1. On the other side is the *operator, which has 2 and 3 as its children.

This tree structure clearly shows what should happen first and what should happen next. The computer can now easily evaluate the expression by following the tree.

Browsers do the same thing with HTML and CSS. They take plain text, parse it, and turn it into tree structures like the DOM and CSSOM so the page can be understood and rendered correctly.

Just remember the flow:

  1. URL entered

  2. Files fetched

  3. HTML → DOM

  4. CSS → CSSOM

  5. DOM + CSSOM → Render Tree

  6. Layout → Paint → Display

Browser

Part 1 of 1