selector.is-superselector($super, $sub) returns a boolean: whether $super matches all elements that $sub matches. It can still be true when $super also matches extra elements. Load with @use "sass:selector".
Official sample idea.
is-superselector("a", "a.disabled") is true (every disabled link is an a); swap the arguments and it is false.
Broader first.
Pass the covering selector as $super and the narrower one as $sub. Argument order matters.
No parent selectors.
Placeholders are allowed; & is not. Need intersection instead of coverage? See selector.unify().
Returns true/false for whether $super covers $sub.
Broader first — argument order is not symmetric.
Extra matches OK — $super may match more than $sub.
Prefer @use "sass:selector" (Dart Sass 1.23+).
One line: to ask whether one selector covers another, use selector.is-superselector($super, $sub).
Practice
Compile Notes
Practical checklist:
checklist.txt
1. @use "sass:selector"
2. Pass broader selector as $super
3. Pass narrower selector as $sub
4. Branch with @if on the boolean
5. Do not pass parent selectors (&)
Frequently Asked Questions
selector.is-superselector($super, $sub) returns true if $super matches every element that $sub matches. It can still be true when $super matches extra elements beyond $sub.
Pass the broader (covering) selector as $super and the narrower one as $sub. Example: is-superselector("a", "a.disabled") is true because every a.disabled is also an a.
No. $super and $sub may contain placeholder selectors, but not parent selectors.
Yes. is-superselector("a.disabled", "a") is false—a.disabled does not match every a.
Yes. is-superselector($super, $sub) is the legacy global name. Prefer selector.is-superselector after @use "sass:selector".
Dart Sass 1.23+. LibSass and Ruby Sass do not load sass:selector with @use; they may still offer the legacy global name.