Re: [csswg-drafts] [css-nesting-1] Syntax Invites Errors (#7834)

For 1, neither does e.g. `@layer`, or JavaScript's `await` keyword. Some feature exist just to improve developer experience and language ergonomics, and this is one of those features.

2 seems pretty clear to me - it has been shown time and time again that nesting is useful for maintainability of stylesheets. It is one of the main features of a CSS preprocessor. Nesting makes CSS easier to write, read, and understand. The benefit of introducing it to CSS is, of course, not needing preprocessors to do this work. An additional benefit is that stylesheets get smaller (because the selectors are shorter than if they were all written out). All together, there is no doubt about whether or not developers want nesting and what problems it would be solving.

3, 4 and 6 - yes, but nesting is a new construct and so this is unavoidable. The amount of complexity added is something we can try to minimize, but it's not something we can completely take away.

5 - yes, but this is irrelevant. IDEs and other tools adapt to the language, not the other way around. 

To be clear, nesting solves the issue of all rules being syntactically identical. If I have 10 rules in a stylesheet with many more rules starting with `.foo `, then these rules are all scoped to be children of an element with class `foo`. This means something, but there's no syntactical distinction between these rules and the other rules. Nesting allows us to show, with syntax, that these rules belong together and form a meaningful group. Additionally, it removes the need to repeat ourselves; we no longer have to start each of these selectors with `.foo `, we can instead start them with just `&`. This makes the rules easier to find, read, and edit.

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


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

Received on Wednesday, 19 October 2022 12:07:07 UTC