Course contentsShow
← Web Development
Lesson 23 of 2,9821. The Web Platform FoundationFree lesson

Constructing the Render Tree

How browsers combine DOM and CSSOM to determine what gets displayed.

Constructing the Render Tree

What you'll learn: How the browser combines the DOM and CSSOM to figure out exactly what should appear on your screen.


The Marriage of Structure and Style

Remember how the browser built two separate trees — the DOM (your HTML structure) and the CSSOM (your CSS styles)? Now comes the crucial step: the browser needs to merge them together to create the Render Tree.

Think of it like planning a stage play. The DOM is your script (who's in the scene), and the CSSOM is your costume and lighting design (how they should look). The Render Tree is the actual staging plan — which actors appear on stage, wearing what costumes, under which lights.

What Makes It Into the Render Tree?

The browser walks through the DOM tree and, for each visible element, finds the matching CSS rules from the CSSOM. Here's the key: not everything in the DOM makes it to the Render Tree.

Elements that won't be displayed are excluded:

  • Elements with display: none in their CSS
  • Elements in the <head> section (like <meta> or <script> tags)
  • Hidden content that doesn't take up space

The Combination Process

For each visible DOM node, the browser:

  1. Finds all matching CSS rules from the CSSOM
  2. Calculates the final styles (combining browser defaults, your CSS, and inheritance)
  3. Creates a Render Tree node with both the content AND its computed styles

The result? A tree containing only what will be painted on screen, with complete style information attached to each piece.


Key Takeaway: The Render Tree combines the DOM's structure with the CSSOM's styles to create a blueprint of only the visible elements that will actually be displayed on your screen.