Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 36 ยท Elements and Styles

The Styles Pane and the CSS Cascade

Read the Styles pane, understand crossed-out rules, specificity and source order, edit CSS live, and use the changes view, with a runnable cascade resolver stand-in.

When you select an element in the Elements panel, the Styles pane on the right lists every CSS rule that applies to it. This is where you answer "why is this text blue?" and "why does my rule have no effect?". To read it well, you need to understand the cascade, the algorithm the browser uses when several rules compete for the same property.

Reading the Styles pane

From top to bottom the pane shows:

  1. element.style: inline styles set on the element (and the place where your live edits land when you click the element's own rule).
  2. One block per matching rule, most important first, each with a selector, its properties and a link to the file and line it came from (for example styles.css:42).
  3. Inherited styles under headings such as "Inherited from body".
  4. At the end, the browser's user agent stylesheet, the default styles for elements such as h1 and ul.

Visual clues are valuable:

  • A property with a line through it was overridden by another rule.
  • A yellow triangle means the property is invalid or unrecognized (a typo, or a value the property does not accept).
  • A checkbox beside each declaration lets you switch it off and on.
  • A grey (faded) property is inherited or is a default not applied.
  • A small ! or a !important flag shows high-priority declarations.

Click the file link to open that rule in the Sources panel.

How the cascade decides

When two declarations target the same property of the same element, the browser picks one using these steps, in order:

  1. Origin and importance: !important declarations beat normal ones; user agent defaults are weakest for normal declarations.
  2. Layers (@layer): later layers beat earlier layers for normal declarations.
  3. Specificity: the selector with higher specificity wins.
  4. Source order: if everything above ties, the rule written last wins.

Specificity is counted as three numbers, written (IDs, classes, tags):

  • An id (#nav) counts in the first slot.
  • A class, attribute selector or pseudo-class (.btn, [type="text"], :hover) counts in the second.
  • A tag or pseudo-element (a, h1, ::before) counts in the third.
  • Inline styles beat all selector specificity. The universal selector * and combinators count nothing.

So #nav a.active is (1, 1, 1) and beats ul li a (0, 0, 3), no matter which is written later. A common reaction is to add !important, but a better fix is to lower the specificity of the over-strong rule or raise the weak one deliberately.

If a rule is crossed out, hover the line to see the reason, and look for the winning rule above it in the Styles pane. The pane is already sorted by priority, so the first rule that sets a property without a strikethrough is the winner.

Editing styles live

  • Click a value to edit it; use the Up and Down arrows to nudge numbers (hold Shift to change by 10, Alt by 0.1).
  • Click an empty space in a rule to add a new declaration; type prop: value and Tab. Autocomplete suggests both.
  • Click the + icon at the top right of the Styles pane to create a new rule for the element (an inspector-stylesheet rule).
  • Right-click a rule for options to copy the rule, copy declarations or copy all declarations.
  • Use the Ctrl+Click on a property name to jump to its definition in the source (variable and property links are clickable).

Everything you change is temporary until you save it through a workspace or copy it into your files. The Changes tool (open it from the drawer or Command Menu) lists every CSS edit as a diff, ready to copy back into your source.

Stand-in: a tiny cascade resolver

The program below implements the cascade for three tiers of selector: ids, classes and tags. It applies !important, then specificity, then source order. It is a teaching model, not the real engine.

JS Stand-in: resolving a property through the cascade

Press Run (or Ctrl + Enter) to see the console output here.

No output.

You can read the printed arrays as (ids, classes, tags). The !important rule wins even though its selector is the weakest, which is exactly why overusing it makes CSS hard to maintain.

Stand-in: finding the dead rule

A very common debugging situation is "my rule is not applied". The next stand-in takes two competing rules and explains why one lost, in the same words you will use when reading the Styles pane.

JS Stand-in: why did my rule lose?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Notice the first line: div .btn has one tag more than .btn, so it wins even though yours came later. In DevTools you would see your rule crossed out beneath it.

Useful extras in the Styles pane

  • :hov and .cls buttons at the top of the pane toggle pseudo-states (:hover, :focus, :active, :visited) and add temporary classes. The next lesson uses them.
  • Hovering a color swatch previews it, and clicking it opens the color picker.
  • Press the Filter box to type a property name or a value and show only matching declarations; use it to find "where is position set?".
  • Computed is a separate tab that shows final values after the cascade; the next-but-one lessons cover it.
  • Rules inside @media, @supports and @layer show the at-rule above the selector, so you can see which condition activated them.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a line through a property in the Styles pane mean?

    A strikethrough means the declaration lost the cascade; a yellow triangle means it is invalid.
  2. 2. Which selector has the highest specificity?

    An id counts in the highest slot, so #menu a is (1,0,1), higher than any of the others.
  3. 3. Two rules have equal specificity and neither uses !important. Which wins?

    When all else ties, source order decides and the later declaration wins.
  4. 4. Where can you see all your temporary CSS edits as a diff?

    The Changes tool lists edits so you can copy them into your source files.

Summary

  • The Styles pane lists matching rules from highest to lowest priority, with sources and strikethroughs.
  • The cascade order: importance, layers, specificity, then source order.
  • Edit values live, add rules, toggle checkboxes, and use the Changes tool to export edits.
  • Prefer fixing specificity over !important.

Next: The Box Model and Layout Debugging