Every time you open a website, something remarkable happens in a fraction of a second. A plain text file full of angle brackets and tags transforms into a colorful, clickable, scrollable page. The software responsible for this conversion is your web browser. Whether you use Chrome, Firefox, or Edge, the browser acts as a translator that reads HTML code and turns it into the page you actually see. Understanding what happens behind the scenes helps you write better web pages and appreciate why the same code can sometimes look slightly different across browsers.
Table of Contents
- The role of web browsers
- How HTML is rendered into a visible page
- Parsing HTML and building the DOM
- Parsing CSS and building the CSSOM
- Building the render tree
- Layout and painting
- Why the DOCTYPE matters
- Popular web browsers and their engines
- Blink, used by Chrome and Edge
- Gecko, used by Firefox
- WebKit, used by Safari
- Why engine diversity affects you
- How browsers handle HTML, SGML, and XML
- SGML, the common ancestor
- HTML as an application of SGML
- XML, a flexible subset of SGML
- Bringing it all together
The role of web browsers
A web browser is far more than a window to the internet. Its main job is to fetch documents from a server and present them to you in a readable, interactive form. When you type a web address, the browser requests the HTML document from the server, receives it as a stream of text, and then begins the work of interpreting that text.
HTML, or HyperText Markup Language, is not a programming language. It is a markup language made up of tags that describe the structure and meaning of content. Tags like <p> for a paragraph, <h1> for a heading, and <img> for an image tell the browser what each piece of content is. The browser reads these instructions and decides how to display them on your screen.
The component inside the browser that does this heavy lifting is called the rendering engine, also known as the layout engine or browser engine. This engine interprets HTML and XML documents along with images and CSS styling, then produces the final layout that appears in the browser window. Every browser has its own rendering engine, and that is one reason pages can look slightly different from one browser to another.
How HTML is rendered into a visible page
The journey from raw HTML to a finished page follows a well-defined sequence often called the critical rendering path. While each browser engine handles details differently, the core steps are remarkably similar across the board. Let us walk through them.
Parsing HTML and building the DOM
The first step is parsing. When the browser receives the HTML document, it does not understand it as a meaningful page yet, only as a string of characters. The engine converts these bytes into characters, then breaks them into tokens through a process called tokenization, and finally links those tokens into nodes. HTML parsing involves tokenization and tree construction, where tokens include start tags, end tags, and attribute names and values.
The result is a tree-like structure called the Document Object Model, or DOM. The DOM represents the entire structure of the page, including every element and attribute defined in the HTML. Each tag becomes a node, and nested tags become child nodes, forming a hierarchy that mirrors how the HTML was written.
Parsing CSS and building the CSSOM
HTML alone describes structure, not appearance. The visual styling comes from CSS. As the browser parses the page, it also reads the CSS rules and builds a separate tree called the CSS Object Model, or CSSOM. This structure holds every style rule, such as colors, fonts, and spacing.
There is an important difference here. The CSSOM cannot be built incrementally because CSS rules can overwrite each other due to specificity, which is why CSS blocks rendering until all of it is parsed. The browser cannot position elements correctly until it knows all the styles that apply to them.
Building the render tree
Once both the DOM and CSSOM exist, the browser combines them into a single structure called the render tree. This tree contains only the elements that will actually be displayed, along with their computed styles. Elements hidden with a property like display: none are left out, since they do not appear on screen.
Layout and painting
With the render tree ready, the browser knows what to display but not yet where. The layout step, sometimes called reflow, calculates the exact position and size of every visible element, taking the viewport dimensions into account. The engine traverses the render tree from top to bottom, working out the coordinates for each node.
Finally comes painting. The browser fills in the actual pixels, drawing text, colors, images, and borders onto the screen. In modern browsers a further compositing step layers these painted sections together for smooth display. After all this happens, you see a fully formed web page, and the entire process usually takes only milliseconds.
Why the DOCTYPE matters
You may have noticed that HTML documents begin with a line like <!DOCTYPE html>. This is the document type declaration, and it plays a quiet but crucial role in how the browser interprets your page. Its main purpose is to tell the browser which rendering mode to use.
When the declaration is present, the browser uses standards mode and follows current web specifications. If it is missing, the browser may fall back to quirks mode, a behavior kept for backward compatibility with old pages designed for older browsers. Quirks mode can cause layout to render in unexpected ways, so a single missing line at the top of a document can quietly change how every style on the page behaves. Interestingly, modern browsers use special-purpose HTML parsers rather than general-purpose ones, so the DOCTYPE is now retained mainly to trigger standards mode.
Popular web browsers and their engines
Different browsers rely on different rendering engines, and a handful of engines power almost the entire web today. Knowing which engine sits inside each browser explains a great deal about how pages behave.
Blink, used by Chrome and Edge
Blink is Google’s open-source engine, and it powers Chrome along with most other Chromium-based browsers. Chrome, Microsoft Edge, Opera, Vivaldi, Brave, and other Chromium-based browsers all use Blink. Microsoft Edge originally had its own engine called EdgeHTML but switched to Blink in 2019. Because so many browsers share this engine, Blink holds a dominant position, with estimates placing Blink at around 79% of the market thanks to Chrome and its many derivatives. It is known for fast performance and rapid adoption of new web features.
Gecko, used by Firefox
Gecko is Mozilla’s engine and powers Firefox. Gecko is valued for strong standards compliance and consistent cross-platform rendering. It appeals especially to users who care about privacy and open standards. Though its market share is smaller than Blink’s, Gecko remains important because it provides genuine engine diversity, giving developers an independent benchmark to test against.
WebKit, used by Safari
WebKit is Apple’s engine and powers Safari. It is optimized for Apple hardware, prioritizing efficiency and battery life on macOS, iOS, and iPadOS. A notable detail is that on iPhones and iPads, every browser, even Chrome and Firefox, must use WebKit under the hood. Blink itself was originally forked from WebKit before Google took it in its own direction.
Why engine diversity affects you
Because each engine interprets code slightly differently, a page can render in subtly different ways across browsers. This is why developers practice cross-browser testing, checking their work in multiple browsers before publishing. The consolidation around Blink has made consistency easier in some ways, but it also reduces variety, and pages optimized only for Blink may break on minority engines like Gecko.
How browsers handle HTML, SGML, and XML
HTML did not appear out of nowhere. It belongs to a family of markup languages, and understanding this family clarifies how browsers treat different document types.
SGML, the common ancestor
The oldest member is SGML, the Standard Generalized Markup Language, which became an ISO standard in 1986 as a way of expressing data in text-processing applications. SGML is not a single language but a framework, a set of rules for creating your own markup languages. It is powerful but complex, which made it difficult for everyday developers to master and unsuitable for delivering content over the web.
HTML as an application of SGML
HTML was designed as a single, fixed application built using SGML’s rules. HTML is an application of SGML, providing one defined set of tags, while SGML provides the capability for creating many different sets of tags. This is why HTML comes with a ready-made vocabulary of elements like headings, paragraphs, and lists. Browsers are built to understand this specific vocabulary, which is why mainstream browsers can display HTML directly but were never built to render raw SGML. In practice, SGML data was usually converted to HTML before being shown on the web.
XML, a flexible subset of SGML
The third member is XML, the Extensible Markup Language, developed by the W3C. XML is based on SGML, but unlike HTML it does not fix the names of tags, so authors can invent their own tags as appropriate. XML was created as a simpler version of SGML, designed to overcome the barriers of delivering full SGML over the web. Where HTML focuses on presenting content, XML focuses on describing and exchanging data in a structured way.
This difference matters for how browsers behave. HTML is forgiving, since browsers attempt to render something on screen rather than display error messages, even when the markup is messy. XML is strict and demands that documents be well-formed, with every tag properly closed and nested. Modern browsers can display XML, often showing its tree structure, but they treat it very differently from the relaxed, presentation-focused way they handle HTML. Many modern web technologies, such as RSS feeds and SVG graphics, are built on XML.
So the family relationship can be summed up simply. SGML is the broad foundation, HTML is one specific language built on it for the web, and XML is a streamlined subset for structured data. Browsers were optimized primarily for HTML, which is why it remains the language of the visible web.
Bringing it all together
When you load a page, the browser fetches the HTML, parses it into a DOM, parses the styles into a CSSOM, combines them into a render tree, calculates the layout, and paints the result on your screen. The rendering engine, whether Blink, Gecko, or WebKit, drives this entire process, and small differences between engines explain why testing across browsers still matters. Behind it all sits a family of markup languages, with HTML serving as the web-friendly application of SGML and XML offering a stricter, data-focused alternative.
What do you think? Now that you know a single missing DOCTYPE line can change how an entire page renders, how carefully do you think developers need to test their work across different browsers? And given that Blink now powers most browsers, do you believe engine diversity is still worth protecting for the health of the web?
References
- https://www.browserstack.com/guide/browser-rendering-engine
- https://developer.mozilla.org/en-US/docs/Web/Performance/Guides/How_browsers_work
- https://starkie.dev/blog/how-a-browser-renders-a-web-page
- https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Quirks_mode_and_standards_mode
- https://en.wikipedia.org/wiki/Document_type_declaration
- https://developer.chrome.com/docs/web-platform/blink
- https://digitechbytes.com/tech-basics-evergreen-fundamentals/browser-engines-2025/
- https://www.geeksforgeeks.org/websites-apps/rendering-engines-used-by-different-web-browsers/
- https://support.unicomsi.com/manuals/systemarchitect/1149/Architecting_and_designing/DesigningXMLschemas1007290.html
- https://www.w3.org/People/Raggett/Drafts/xml.html
- https://help.genesys.com/cic/mergedprojects/wh_soap/desktop/what_is_the_relationship_between_xml_and_markup_languages_such_as_html_or_sgml.htm

Leave a Reply