Low-Specificity CSS Reset with :where()
Low-specificity resets without complicated selectors
Resets used verbose low-specificity tricks, or you fought them later with higher specificity. :where() has zero specificity so it never wins over your component styles.
The old hack vs the modern fix
View demo.prose ul, .prose ol {
margin: 0;
padding-left: 1.5rem;
}
/* Specificity (0,1,1). Component .list { padding: 0 } loses. */:where(.prose ul, .prose ol) {
margin: 0;
padding-inline-start: 1.5rem;
}
/* Specificity 0. .list { padding: 0 } wins. */Where browser support
Live demo
Why the modern way wins
Zero specificity
:where() strips specificity from its argument. Your reset never overrides component styles.
No !important
No need to bump specificity or use !important in components to beat the reset.
Same syntax as :is()
Drop in :where() where you would use :is(). Same selector list, zero specificity.
- Specificity
- 0
- Resets never win over components
- Old Approach
- Tag selectors or .reset
- Fight specificity later
- Modern Approach
- :where()
- Zero specificity resets
How it works
The old approach was either very specific selectors for resets (so they applied) or low-specificity hacks that were still hard to override. A bare tag selector like ul has specificity (0,0,1), so a class like .list at (0,1,0) beats it. But once the reset is scoped, like .prose ul at (0,1,1), that same class loses and you have to add more specificity or !important in components.
:where(.prose ul, .prose ol) accepts the same selector list as :is(), but the whole thing gets zero specificity. So your reset applies by order in the cascade, but any single class or ID in a component beats it. Use :where() for resets, base styles, and defaults you want to be easy to override.