-
Notifications
You must be signed in to change notification settings - Fork 686
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-nesting-1] Should prefixing nested selectors be mandatory? #8270
Comments
The "clarity for authors" argument appears to be completely theoretical. The current syntax is more or less what has been supported in many widely-used preprocessors for over a decade, and there doesn't seem to have been any significant confusion on author's parts. We're not exploring new space here; this is a well-trod cowpath. Using the & as the mandatory prefix as well as a nesting selector is absolutely a no-go - that is legitimately extremely confusing that If we were to go with mandatory prefixing we'd use |
Requiring
which results in There has been discussion of using a different symbol. Keep The CSSWG has discussed mandating a prefix (whichever the character) quite a bit already. And settled on no — because we value author's ability to more easily copy & paste code in/out of a nested context. All that said, I believe we should not make prefixing nested selectors mandatory because of the Robustness principle (also known as Postel's law): "be conservative in what you send, be liberal in what you accept". Web technology has been designed with a set of principles in mind, to rely on when debating questions exactly like this one. Some developers want the mandatory symbol, others do not. So which is the right choice? We could debate pros & cons forever and still not agree. Underlying design principles are the right place to look to guide decisions in such situations. According to the Robustness principle, CSS should lean towards more flexibility in how authors write their selectors, not less. If they want to always use a I do not believe we should violate the Robustness principle for this case. |
My understanding of the "require & prefix" idea is that & at the start only substitutes to
And I agree that the Robustness principle should be the guide. |
The CSSWG already discussed and rejected prefixing every rule, see https://lists.w3.org/Archives/Public/www-style/2022Oct/0022.html @SebastianZ is there some new information that you wanted to bring to the table that requires re-opening that question? |
As mentioned in #8248, some people expressed support for making the ampersand in nested rule selectors mandatory. Some discussion already happened in the other issue, though here's a summary of its advantages and disadvantages:
Advantages:
&::before
vs.& ::before
)Disadvantages:
&
later in the selector (in case&
is used as prefix and reference for elements matched by the parent rule)Sebastian
The text was updated successfully, but these errors were encountered: