Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-variables-2] Is it possible in the future to allow variables to be defined outside the elements' {}? #8159

Closed
LIXiangChen opened this issue Nov 30, 2022 · 2 comments

Comments

@LIXiangChen
Copy link

What I mean is that when defining CSS variables, it is not necessary to write it in the elements' {}, which is equivalent to a syntactic sugar, and the variables are implicitly bound to the :root element.

For example, the following two codes will be equal:

@media (max-width: 800px) {
    --foo: 123;
}
@media (max-width: 800px) {
    :root {
        --foo: 123;
    }
}
@tabatkins
Copy link
Member

No, this can never happen. Mixing properties and selectors at the same level is problematic - see the long discussion in #7834, where we have to do a lot of work to allow mixing properties with nested selectors.

In particular, the current solution in the spec for nested rules disallows starting a selector with an identifier (aka a tagname selector), which we definitely can't retroactively apply to all existing CSS. ^_^

@LIXiangChen
Copy link
Author

@tabatkins Got it. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants