How Browsers Work

How Browsers Work

What your browser does to turn HTML into the page you see

What you'll learn

  • What a browser and its engine do
  • How HTML becomes the DOM tree
  • How style, layout and paint turn the DOM into pixels
  • How JavaScript, the cache and tabs fit in

A browser fetches web pages and draws them on your screen. Chrome, Safari, Firefox and Edge each have an engine that does the work: Blink in Chrome and Edge, WebKit in Safari and Gecko in Firefox. First the browser fetches the page. It finds the server's IP address with DNS, sets up a secure connection, sends an HTTP request and gets back HTML.

HTML is just text. The browser reads it from top to bottom and builds the DOM, a tree with a node for each tag. It also asks for the CSS, JavaScript and images the page links to, without waiting for one file before asking for the next. It matches the CSS rules to the nodes to work out each one's style, works out where everything goes and how big it is (layout), then fills in the pixels (paint).

JavaScript makes the page interactive. The JavaScript engine, like V8 in Chrome, runs code that can change the DOM, and the browser then updates the layout and paints again. The cache keeps files you've already downloaded, so pages load faster next time. Each tab usually runs in its own process, so a crash in one tab doesn't take down the others, and one site can't read what's open in another tab.

More videos

35 short explainers so far, with more on the way

View all videos

Join the Community

roadmap.sh is among the top 10 most starred projects on GitHub and is visited by hundreds of thousands of developers every month.

Top 10 out of 28M!

371K

GitHub Stars

Star us on GitHub
Help us reach #1

+90kevery month

+3.2M

Registered Users

Register yourself
Commit to your growth

+2kevery month

52K

Discord Members

Join on Discord
Join the community

RoadmapsGuidesFAQsYouTube

roadmap.shby@nilbuild

Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.

© roadmap.sh·Terms·Privacy·

ThewNewStack

The top DevOps resource for Kubernetes, cloud-native computing, and large-scale development and deployment.