v148 · CSS
The revert-rule keyword
Roll back individual CSS declarations to whatever the cascade provided before the current rule — without touching any other property. A surgical undo for the cascade.
concepts
-
Cascade Unwinder
A component with multiple stacked rules. Toggle
revert-ruleon individual properties and watch the cascade peel back — one rule at a time — to the previous declared value. -
Conditional Polish
Style a button for light and dark mode. Use
revert-ruleinside@media (prefers-color-scheme: dark)to cleanly undo specific overrides instead of re-declaring every changed property. -
Component Reset Demo
The same button, input, and select styled four ways: unmodified author styles,
revert-rule(undo only this rule),revert(undo all author styles back to UA), andinitial(CSS spec default). See exactly when each keyword is the right tool. -
Cascade Debugger
A visual cascade tool. Six layers (UA, author base, @layer component, @layer theme, @layer utility, inline) contribute to a subject element. Toggle
revert-ruleon any layer to watch the cascade re-evaluate. A computed styles panel with an Origin column shows exactly where each property value came from, plus a live CSS editor. -
Layer Reset Demo
Three-layer design system (base → theme → overrides) with live controls that place
revert-rulein different override rules. See when it falls back to an earlier rule in the same layer and when it continues to a lower-priority layer.
why it shipped
revert rolls back to the browser UA stylesheet. revert-layer rolls back to the previous cascade layer. But until now there was no way to roll back to the previous rule within the same layer — useful when you want to undo a theme override or a conditional tweak without re-specifying every property you want to keep. The revert-rule keyword fills that gap: it says "for this property, act as if this rule didn't exist" while leaving every other declaration in the rule untouched.
references
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗