Re: [csswg-drafts] [css-pseudo] Custom properties on :root (#6641)

Just pasting my comments here from the [other thread](https://github.com/w3c/csswg-drafts/issues/6931) since the issue is discussed here now: 

> This keeps coming up. We don't want authors to be duplicating colors in these rules, but also we don't want a dependency on the root element's computed style. What if we define a new rule (`::document`?) where authors can define values for custom properties that are **above** the root node, i.e. akin to applying to the actual document node. Then media queries and other at rules can use `var()` references, and they'd resolve relative to that, and because it's not an element, nothing depends on any element's computed style.

> @tabatkins
> 
> > @LeaVerou do you have an objection to the suggestion Anders made, to rely on the initial value of custom props, as defined by `@property`? Note that you can nest @Property in MQs and other conditionals if needed, to supply the "right" initial value.
> 
> I think that's a clumsy solution, as it requires a new `@property` rule for every single property. Authors tend to define A LOT of properties in their root rules ([eg](https://github.com/twbs/bootstrap/blob/main/dist/css/bootstrap.css#L9)). Even when `@property` is widely supported, I don't see authors using it for every single custom property they define. Certainly better than nothing though!



-- 
GitHub Notification of comment by LeaVerou
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6641#issuecomment-1108824207 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 25 April 2022 17:06:04 UTC