:where() Is :is() Without the Specificity

Recent discussion around the :is() relational pseudo-selector has focused on readability: the function makes compound selectors easier to parse. Its behavior around specificity is the part worth flagging.

A :is() selector takes the specificity of the most specific selector among its arguments. In a flat style structure built mostly from element and class selectors that rarely matters, but a single ID in the argument list sets the specificity for the whole selector.

That behavior can be used deliberately. Dropping a made-up ID into the arguments forces a style in much the same way the !important keyword does. Some articles suggest nesting selectors to avoid the specificity instead, which works but loses the writing ergonomics.

The alternative is :where(), which behaves identically to :is() but carries none of the specificity. Its specificity score is always zero — effectively a reset for the selector's weight. So when some selector is hijacking the specificity of an :is(), :where() is the replacement to reach for.