Intent to Prototype: The 'revert-rule' Keyword

121 views
Skip to first unread message

Anders Hartvoll Ruud

unread,
Aug 28, 2025, 3:05:40 AM (8 days ago) Aug 28
to blink-dev

Contact emails

and...@chromium.org

Explainer

None

Specification

None

Summary

The 'revert-rule' keyword rolls back the cascade to the previous rule, similar to how revert-layer rolls back the cascade to the previous layer. For example: ``` div { color: green; } div { color: revert-rule; /* Effectively green */ } ``` This is especially useful in combination with conditionals, as it allows eliminating the current rule if some condition is not met: ``` div { display: if(style(--layout: fancy): grid; else: revert-rule); } ```


Without 'revert-rule', you would either need to know which value exactly you would be "reverting" to (i.e. specify a literal 'block'/'inline'/etc in place of 'revert-rule'), or use 'revert-layer' (which requires wrapping your rule in an otherwise unnecessary anonymous layer).



Blink component

Blink>CSS

Motivation

None



Initial public proposal

CSSWG resolution to add the keyword.

TAG review

None

TAG review status

Pending

Risks

The style team was initially worried that keeping track of all (or most) of the declarations in the cascade in a "revertible" form would cause performance regressions, but the benchmarks run so far show no significant difference.

Interoperability and Compatibility

None



Gecko: No signal

WebKit: No signal

Web developers:



Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

None



Debuggability

None



Is this feature fully tested by web-platform-tests?

No

Flag name on about://flags

None

Finch feature name

None

Non-finch justification

None

Requires code in //chrome?

False

Estimated milestones

No milestones specified



Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5146458504429568?gate=5171636433190912

This intent message was generated by Chrome Platform Status.
Reply all
Reply to author
Forward
0 new messages