How a Browser Works
The browser was just one single app that "opens websites." I realized it’s actually a collection of huge components working together like a factory

Introduction
Welcome back to the series! If you’ve been following along, we just spent weeks talking about cables, DNS, and TCP. We basically acted like delivery drivers, just trying to get the package (the website data) from the ocean to your laptop. But now, the package has finally arrived. The delivery is done. Now the real magic starts.
I used to think the browser was just one single app that "opens websites." You click Chrome, type a URL, and boom, Facebook appears. But after digging into the internals, I realized it’s actually a collection of huge components working together like a factory. It’s not just one thing; it’s a team.
What is a Browser, Actually? So, let's break down this "team." When you look at the diagram (the black one with the boxes), you see the User Interface at the top. That’s the part you click on, the address bar, the back button, the bookmarks. That’s just the dashboard. But the real boss is the Browser Engine. This guy sits in the middle and manages everything. He takes orders from you (the UI) and tells the Rendering Engine what to do.

The Rendering Engine is the star of the show today. In Chrome, it's called "Blink" (part of Chromium), and in Firefox, it's "Gecko." Its only job is to take your code, the HTML and CSS and paint it onto the screen. It also talks to other small workers like Networking (who fetches the images) and the JS Interpreter (who runs the JavaScript logic). But mostly, it’s about drawing pixels.
Step 1: HTML to DOM So, how does it actually draw? Imagine the browser receives your HTML file. To the computer, it’s just a long string of text and numbers. It means nothing. The browser has to "parse" it, which is just a fancy word for translating. It reads the file character by character. It sees a < tag, then div, then >, and realizes, "Oh, this is a box."
It takes all these tags and builds a tree structure called the DOM (Document Object Model). I like to think of the HTML as the script for a movie, and the DOM is the director organizing the actors. The browser creates a "Node" for every element, a node for the <body>, a node for the <div>, a node for the text inside. By the end, it has a full family tree of your content.

Step 2: CSS to CSSOM But a movie script is boring without costumes. While the browser is building the DOM, it finds a link to your CSS file. It screams, "Hey Networking, go get this file!" Once the CSS arrives, the browser reads it just like the HTML.
It builds another tree called the CSSOM (CSS Object Model). This tree is all about style. If the DOM says "There is a Headline here," the CSSOM says "The Headline is Red and 50px big." It attaches these rules to the nodes. It’s like the costume department measuring the actors and deciding what they will wear.
Step 3: Render Tree Now comes the marriage. The browser combines the DOM (content) and the CSSOM (style) into something called the Render Tree. This is important because the Render Tree only contains things that will actually appear on the screen.
For example, if you have a div that says display: none, the DOM has it, but the Render Tree ignores it. It’s invisible. The Render Tree is the final list of "Actors who are going on stage right now."

Step 4: Layout Now the actors are in costume and ready, but where do they stand? This step is called Layout (or Reflow). The browser looks at your screen size (the viewport). It does the math. It calculates exactly where every box goes.
It says, "Okay, this Header is 100% width, so it goes all the way across. This button is 20px from the left." It draws a geometry map of the page. It’s like the set designer using a measuring tape to mark exactly where the furniture goes on the stage so nobody bumps into each other.

Step 5: Paint Finally, we have the Paint stage. This is where the pixels actually light up on your screen. The browser takes that geometry map and fills it in. It draws the text, colors the background, adds the shadows, and renders the images.
This happens incredibly fast. And the crazy part? If you change something, like if you resize the window or hover over a button, the browser might have to run through this whole process again. It has to re-calculate the Layout and Re-Paint the pixels. That’s why complex animations can sometimes make your laptop fan spin!

Conclusion So that’s it. That’s the journey. It starts as a text file, turns into a DOM tree, gets dressed up by CSSOM, gets measured in the Layout, and finally gets Painted as pixels. It’s a messy, complex factory running inside your computer, and it does all of this in milliseconds just so you can see a meme. Pretty cool, right?
Now that we know how the browser processes code, we need to learn how to write it. We know the browser builds a DOM Tree... but what are the branches made of? They are made of HTML Tags.
In the next blog, we start a new series! We will stop talking about theory and start coding.





