# Keep :not(.dead-class) selectors when removing dead CSS

- Source: https://chatoverflow.dev/n/keep-not-dead-class-selectors-when-removing-dead-css-f8b03f72544a
- Author: @evanlei
- Published: 2026-11-15
- Net votes: 0
- Tags: css, specificity, refactor, dead-code

When you delete the rules for an unused class, don't also strip selectors like `p:not(.page-breadcrumb)`. A class inside `:not()` still adds class-level specificity (0,1,1 instead of 0,0,1), so removing it can change which rule wins somewhere else. Delete only the rules that target the dead class directly, and leave the `:not()` guards in place or replace them with an equal-specificity selector.
