All posts
Web Development · 8 min read · May 14, 2026

Understanding browser rendering: DOM, CSSOM, render tree, and paint

Browser rendering pipeline from HTML to pixels

When a browser loads a page, it does far more than simply display the HTML you wrote. It runs a carefully ordered pipeline that turns markup and styles into the pixels you see on screen. Understanding this pipeline - often called the critical rendering path - helps you reason about performance, debug layout issues, and avoid the patterns that make pages feel slow.

The critical rendering path

The browser converts HTML and CSS into a live, interactive page through a sequence of steps. Each step depends on the one before it, so a delay early in the pipeline ripples through everything that follows.

  1. Parse HTML into the DOM (Document Object Model).
  2. Parse CSS into the CSSOM (CSS Object Model).
  3. Combine the DOM and CSSOM into the render tree.
  4. Run layout (also called reflow) to compute the geometry of every visible node.
  5. Paint the pixels for each node.
  6. Composite the painted layers into the final image on screen.

The DOM

As the browser reads HTML, it builds the DOM - a tree of nodes that represents the structure of the document. Each element, attribute, and piece of text becomes a node. The DOM is what JavaScript interacts with when you call methods like document.querySelector or element.appendChild.

HTML parsing is incremental: the browser builds the DOM as bytes arrive, which is why a script placed early in the document can block parsing of everything below it.

html
<body>
  <h1>Profile</h1>
  <p class="bio">Backend engineer.</p>
</body>
This markup becomes a DOM tree: body > (h1, p.bio > text).

The CSSOM

In parallel, the browser parses every stylesheet into the CSSOM - a tree of style rules and their relationships. Unlike HTML, CSS is render-blocking: the browser will not paint until the CSSOM is complete, because applying styles partially could cause a flash of incorrectly styled content.

This is why large or slow-loading stylesheets delay the first paint, and why inlining critical CSS for above-the-fold content can make a page appear faster.

The render tree

The browser combines the DOM and CSSOM into the render tree, which contains only the nodes that will actually be displayed. Elements hidden with display: none are excluded entirely, while elements with visibility: hidden remain in the tree because they still occupy space.

Each node in the render tree carries both its content and its computed styles, giving the browser everything it needs to figure out where things go.

Layout and paint

Layout (reflow) calculates the exact position and size of every node - its box, margins, and coordinates. Paint then fills in the pixels: text, colors, borders, shadows, and images. Finally, compositing assembles separate layers (for example, elements being animated) into the picture you see.

Reflow is expensive because changing one element's geometry can force the browser to recompute many others. Repaint is cheaper but still costs time when it covers large areas.

Why this matters for performance

Knowing the pipeline tells you which changes are cheap and which are expensive. Changing a property that affects geometry (width, height, top, margin) triggers layout. Changing a paint-only property (color, background) triggers repaint. Changing transform or opacity can often be handled by the compositor alone, skipping layout and paint entirely - which is why those properties are preferred for smooth animations.

ChangeTriggersCost
width, height, top, marginLayout → paint → compositeExpensive
color, background, box-shadowPaint → compositeModerate
transform, opacityComposite onlyCheap
Prefer transform and opacity for animations to avoid layout and paint.

Practical takeaways

  • Keep render-blocking CSS small and load non-critical styles asynchronously.
  • Defer or async non-critical scripts so they do not block DOM construction.
  • Batch DOM reads and writes to avoid forcing repeated layouts (layout thrashing).
  • Animate with transform and opacity instead of properties that trigger layout.
  • Use the browser's Performance panel to see where layout and paint time is spent.

Conclusion

The journey from HTML to pixels is a predictable pipeline: DOM, CSSOM, render tree, layout, paint, composite. Once you understand each stage and what triggers it, performance work stops being guesswork. You can look at a janky animation or a slow first paint and know exactly which part of the pipeline to investigate.

Contact

Let’s connect

Have a Liferay or Backend project you’d like to talk through? Fill in the form and I’ll get back to you.

Book Calendar