Skip to content
Fallow home
All docs pages

Docs home

CSS selector complexity

What a css-selector-complexity finding of fallow health means, why it matters and how to fix it.

What it reports

CSS selector, nesting, or important usage is structurally complex.

Styling explains how fallow finds it.

Why it matters

A selector with high specificity or !important wins over later rules, so the next style change needs a stronger selector. A long descendant chain also breaks when the markup changes.

Example

.sidebar nav ul li a.active sits four levels deep in nested SCSS, and its block uses !important on most declarations.

Fix

Flatten the nesting, put a class on the element instead of a long descendant chain, and remove !important where the order of the rules can do the work.

Facts

FactValue
Issue typecss-selector-complexity
Rule id in SARIF outputfallow/css-selector-complexity
Commandfallow health
Default severitywarn
Config key in rulescss-selector-complexity
Suppression comment// fallow-ignore-next-line css-selector-complexity
Fixable with fallow fixNo
Opt-inNo

When to keep the code

  • A reset rule, an accessibility rule, or a rule that overrides markup of another library can need a strong selector.