Skip to content
Astera Technology

Scope a default with a zero-specificity context

Compare :where(.lesson) p with a plain .lesson p selector.

The highlight class wins over the zero-specificity context plus p.

Download complete case notes and answer keys ↓

Inspect the working example

The scoped default is gray. The highlighted paragraph should be green. :where contributes zero specificity for its entire argument.

Inputs and native observations
CaseInput or inspectionResult and meaning
Default selector:where(.lesson) pOnly p contributes specificity
Override.highlightClass specificity wins
ResultInspect computed colorrgb(0,80,40)
Download editable CSV ↓

Follow the browser mechanism

:where can match a context without adding its argument’s specificity. That keeps this default easy to override. It does not stop matching descendants and does not establish a cascade layer.

The plain context adds a class and a type

The alternative uses .lesson p for the same gray default.

Counterexample source; inspect separately
<style>body{margin:8px}</style>
<style>.lesson p{color:rgb(90,90,90)}.highlight{color:rgb(0,80,40)}</style><section class="lesson"><p class="highlight">Highlighted workshop note</p></section>

The class-plus-type default outranks the class-only override and leaves the paragraph gray.

Try the repair

Does putting .highlight later always defeat a more specific .lesson p rule?

Show the worked answer

No. Source order only breaks the appropriate ties after earlier cascade criteria, including specificity, are equal.

  • Compare exact matched selectors and computed colors.
  • Keep scope matching separate from specificity.

Original example files

Related resources