Skip to article content
FrontendXLesson 05 / 20

CSSOM and the Cascade

Build an accurate mental model of what the browser does, from navigation and HTTP through parsing, rendering, storage, workers, security, and DevTools, so you can predict behavior and debug real pages.

intermediate · about 35 minutes · 2 exercises

  • Predict
  • Explain

What you will be able to do

#
  • Compute the winning declaration from origin, specificity, and order.
  • Distinguish computed values from used values.
  • Explain why CSS is render-blocking.

Overview

#

CSS is parsed into the CSSOM, a tree of style rules the browser can query quickly.

Cascade order

When several rules match, the winner is decided by, in order: origin and importance, specificity, then source order. Inline styles beat author stylesheets unless !important is involved, and user-agent styles lose to author styles.

Specificity

Specificity is a tuple: (inline, ids, classes/attributes/pseudo-classes, elements/pseudo-elements). #a .b p is (0,1,1,1) and beats .b p at (0,0,1,1).

Computed and used values

Computed values resolve things like relative units and inheritance. Used values resolve layout-dependent things such as percentages of the containing block. The Computed tab in DevTools shows computed values, not the exact used geometry.

Render blocking

A stylesheet in the head blocks rendering because the browser will not paint with incomplete styles. @import inside CSS adds a serial request and delays rendering further.

Questions to carry forward

  • How do layers change cascade order?
  • What is the difference between computed and used values?
  • Why is inline critical CSS faster?

Exercises

#

Reference answers and expected output are authored, not executed in this browser. Nothing you type is run, and there is no Run or Pass control on this page.

  1. Exercise 1Predict

    Which rule wins for the color of this element?

    Read the code, then choose the best answer. The reference explanation stays hidden until you respond.
    stimulus.css
    <style>
      .card p { color: green; }
      #main .card p { color: blue; }
      p { color: red; }
    </style>
    <div id="main"><div class="card"><p>text</p></div></div>
    Choose the best answer
  2. Exercise 2Explain

    Explain why a large stylesheet in the head can delay the first paint even if the HTML is already downloaded.

    Reveal the reference answer
    reference.text
    The browser will not build the render tree or paint until the CSSOM is complete, because painting with partial styles would cause a flash of unstyled content. So a slow or large stylesheet blocks the render tree and the first paint.

    Authored expected output: An answer linking the CSSOM to the render tree and first paint.

    Rendering needs both the DOM and the CSSOM. Missing CSS means no correct render tree, so paint waits.

Common misconceptions

#
  • Specificity alone decides the winner, ignoring origin and importance.
  • The Computed tab shows final pixel geometry.
  • @import loads in parallel with the parent stylesheet.

Follow-up practice

#
  • browser-internals-render-tree-layout

Related resources

#

Your progress

#

Answers, drafts and completion marks are stored only in this browser. Nothing is sent to a server and no account is used.

Verification: authored. Answers and outputs on this page are authored reference material, not executed results.

© 2026 FrontendX. All rights reserved.