Intent to prototype and ship: CSS revert-rule keyword

57 views
Skip to first unread message

Emilio Cobos Álvarez

unread,
Mar 3, 2026, 4:26:49 PM (4 days ago) Mar 3
to dev-pl...@mozilla.org
Summary: Add a CSS-wide keyword that allows reversing a single rule from the cascade, rather than a whole origin (like revert) or a layer (revert-layer). This is useful for var() / attr() / if(), though note we don't implement the later. E.g. you can use something like `width: attr(width px, revert-rule)`, and the declaration will be ignored unless you have a width attribute.
Standards Body: CSS WG
Platform coverage: All
Preference: layout.css.revert-rule.enabled
Extensions bug: N/A
Use counter: None [0]
Link to standards-position discussion: https://github.com/mozilla/standards-positions/issues/1358
Other browsers:
web-platform-tests: See the bug, there's a variety. Note that our implementation suffers from a couple issues, but those are common to the pre-existing revert keywords and haven't caused issues in practice: behavior in @keyframes (bug 1533327), and behavior with dependent properties (csswg-drafts#9131). I don't think these are blockers given that.

Let me know if there's any concern with proceeding.

Cheers,
 -- Emilio

[0]: While we have somewhat comprehensive machinery to measure CSS values when parsing, we have two issues that make it non-trivial to measure the right thing:
  • CSS wide keyword parsing has many entry points due to their nature, not all of them carrying the right context (so measuring parsing right would be kind of a PITA).
  • Parsing wouldn't be the right thing to measure anyway. Ideally, we'd want to count it at cascade time instead (when the value is actually used). However we don't have an easy way to do that right now (and I don't think it's worth it for a relatively simple feature). I can look into adding that separately, filed bug 2020819.
Reply all
Reply to author
Forward
0 new messages