Core question: How does a browser turn flat text files of HTML, CSS, and JavaScript into interactive pixels on your screen in milliseconds?
When a server responds to your browser, it doesn't send a finished picture of a website. It sends plain text files filled with code (index.html, style.css, app.js). Yet somehow, within a blink of an eye, your screen displays a rich layout with custom fonts, rounded buttons, drop shadows, and smooth animations.
The part of the browser responsible for this magic is the Rendering Engine (such as Blink in Chrome, WebKit in Safari, and Gecko in Firefox).
To turn raw text into pixels, the Rendering Engine runs a strict five-step assembly line known in software engineering as the Critical Rendering Path (CRP).
Imagine you are building a house. You wouldn't start painting walls before the framing is up, and you wouldn't put up framing before reading the blueprints. The Rendering Engine follows that exact same logic:
First, the Rendering Engine reads your raw HTML file from top to bottom. As it sees tags like <html>, <body>, <div>, and <p>, it converts them into a live family tree of objects in the computer's memory called the DOM (Document Object Model).
<button> lives inside a <form>, which lives inside the <body>.While reading the HTML, the browser discovers a link to your stylesheet (style.css). It reads all the CSS rules (like p { color: navy; font-size: 16px; }) and builds a second tree called the CSSOM (CSS Object Model).
Next, the engine marries the DOM (structure) and the CSSOM (styles) together to create the Render Tree.
<head> or <script>) and any element hidden with the CSS rule display: none are completely left out of the Render Tree. (Note: An element styled with visibility: hidden is invisible, but still takes up an empty gap on the page—so it stays in the Render Tree!)At this point, the browser knows which elements are visible and what colors/fonts they use, but it still doesn't know how big they are or where they sit on your specific screen.