Rendering PipelineBaseline · Widely

Render Tree & Layout

Mental Model

The Render Tree combines visible DOM nodes with their resolved CSSOM styles, omitting display: none subtrees while keeping visibility: hidden boxes. The Layout phase then computes the exact width, height, and (x, y) coordinates of every remaining box.

Interactive Simulator

DOM + CSSOM to Physical Box Geometry

Inspect how display: none, visibility: hidden, and text nodes map into the Render Tree.

DOM
ComputedStyle
Box Tree
Geometry
Step 1 / 3: 1. Style Resolution

Engine matches CSSOM selectors against DOM elements to produce ComputedStyle per node.

.hidden { display: none; } .ghost { visibility: hidden; }
Internal State / Memory
domNodes
5
styledNodes
5
omitted
0

Under the Hood

Blink constructs the Render Tree by pairing visible DOM nodes with resolved ComputedStyle structs, omitting display: none subtrees while keeping visibility: hidden boxes in flow. Like a carpenter's cut-list, anything marked display: none is crossed off before Layout measures widths, heights, and coordinates.

  1. Style Recalc: The engine resolves cascade rules for every DOM element into a ComputedStyle struct.
  2. Box Generation: Visible elements generate one or more layout boxes (including anonymous boxes for bare text runs and ::before pseudo-elements).
  3. Geometry Solving: Layout traverses the box tree to compute intrinsic sizes, line breaks, and viewport-relative coordinates.
CSS
/* Omitted from Render Tree: 0 layout cost, no box generated */
.collapsed-panel { display: none; }

/* Kept in Render Tree: reserves space and participates in Layout */
.invisible-placeholder { visibility: hidden; }

Once DOM & CSSOM Construction finishes, reading geometry properties like offsetWidth prematurely triggers Layout Thrashing.

Problem Genealogy

  • 1999–2015: Legacy layout engines mixed inline, block, and table state in mutable trees, causing O(n^2) reflow bugs.
  • 2019+ (Blink LayoutNG / Gecko): Engines moved to immutable fragment trees, isolating layout inputs from outputs for predictable caching.

Production Pitfalls

Production Pitfall
  • Toggling display: none on complex widgets: Destroying and rebuilding layout boxes discards cached line-breaking and intrinsic-size state.
  • Unbounded DOM depth: Deeply nested flex or grid containers multiply layout passes when parent and child constraints depend on each other; cap long feeds with Virtualized Lists & Windowing.
When Not to Use
  • When not to use display: none: Avoid display: none for elements toggled every frame or holding measured scroll positions; use visibility: hidden or content-visibility: hidden instead.

Connections & Logical Next Steps

What This UnlocksBaseline · Widely
Block Formatting Context (BFC)
CSS & Layout

BFCs partition the Layout box tree into independent block-flow regions.

What This UnlocksExperimental
CSS Anchor Positioning
CSS & Layout

Anchor positioning resolves inset coordinates during Layout without JS getBoundingClientRect() reads.

What This UnlocksBaseline · Widely
CSS Containment
Rendering Pipeline

Layout containment prevents subtree geometry changes from invalidating ancestor boxes.

What This UnlocksBaseline · Widely
CSS Scroll Snap
CSS & Layout

Scroll snap positions derive from laid-out child snap-area boxes and scroll-padding.

What This UnlocksBaseline · Widely
Dynamic Viewport Units (dvh, svh, lvh)
CSS & Layout

Viewport units resolve during Layout against the small, large, or dynamic viewport box.

What This UnlocksBaseline · Widely
Paint & Rasterization
Rendering Pipeline

Paint requires resolved box coordinates from Layout to record drawing bounds.

What This UnlocksBaseline · Widely
Simulated DOM (JSDOM/HappyDOM) vs Real Browser Engines
Testing & Verification

Real browser engines compute box geometry during layout; simulated DOMs return static zeros.

Useful PrerequisitesBaseline · Widely
DOM & CSSOM Construction
Rendering Pipeline

Render Tree construction cannot begin until DOM nodes and CSSOM rules exist.

Useful PrerequisitesBaseline · Widely
Browser Rendering Pipeline (Critical Rendering Path)
Rendering Pipeline

Layout is the geometry-solving stage inside the main-thread frame pipeline.

Under the HoodBaseline · Newly
content-visibility & Skipping Offscreen Work
Rendering Pipeline

Skipped subtrees retain their DOM nodes but bypass Layout and Paint until near the viewport.

Under the HoodBaseline · Widely
CSS Logical Properties
CSS & Layout

Resolves inline and block properties to physical box edges during layout box generation.

Under the HoodBaseline · Newly
CSS Subgrid
CSS & Layout

Synchronizes nested subgrid item geometry with parent grid tracks during layout calculation.

Under the HoodBaseline · Widely
Device Pixel Ratio & Subpixel Rendering
Rendering Pipeline

Layout computes fractional CSS pixels before Paint snaps borders and transforms.

Often Confused WithBaseline · Widely
Virtualized Lists & Windowing
State & Architecture

Full-list DOM rendering forces layout over thousands of off-screen boxes, whereas virtualization caps active layout nodes to the viewport.

Seen in Architecture Autopsies

Mechanical Comparisons