Live data from Hacker News

Help choose the syntax for CSS Nesting

webkit.org

131–140 of 170 posts

Re: Help choose the syntax for CSS Nesting

#131
post #85

Earlier quoted context omitted.

Nesting is a solution in search of a problem. Combining classes has worked fantastically for me over the last 15 years.

that's great, but sometimes when I start vanilla side projects I like to take a CSS Zen Garden approach to things. That's harder to do the more tightly you couple your HTML and your CSS

The stylesheets for CSS Zen Garden examples are more tightly coupled to the HTML than any other CSS I've ever seen in my life. They literally have no use against any other block of HTML than that one page.

Re: Help choose the syntax for CSS Nesting

#133
post #26

I think the reason this debate continues to rage on is that all of the options are worse than what is currently available with pre-processors. If CSS can’t match or improve on the obvious syntax used by sass then they should not implement it. All of these options are confusing. Nesting is not a requirement for CSS. Just let it go and if you want nesting use sass.

I try not to use preprocessors or bundlers/build tools for simple stuff so the addition of features like this to the base CSS language is something I look forward to.

Re: Help choose the syntax for CSS Nesting

#134

Earlier quoted context omitted.

> These options are bad, and CSS does not need this. 1. You don't have to use it if it doesn't seem useful to you. 2. Many developers (me included) use Sass and other preprocessors so they can use nesting; it's probably the single most popular feature of Sass. 3. CSS doesn't need nesting but a lot of developers want it, as it improves the developer experience for writing complex selectors.

The group in 3 can use SASS. At this point you should view CSS like assembly, convenience functions go at a higher level.

I hope web standards decisions are never made starting from the assumption that there's a build tool.

Re: Help choose the syntax for CSS Nesting

#136
post #19

I want browsers to have first class Sass support. Pave the cowpaths etc.

> I want browsers to have first class Sass support. We don't want that. For example, CSS Custom Properties (CSS variables) are far more powerful than Sass variables. Plus you'd have two different implementations for how variables work—CSS variables work with the cascade but Sass variables don't. You can't have two fundamentally different methods for variables. That's a non-starter. Pretty much all of the good stuff f…

> We don't want that.

Statistically, we do. Sass won the precprocessor wars and nearly every developer prefer SCSS variables over the var(--oh-god) that is CSS syntax.

> For example, CSS Custom Properties (CSS variables) are far more powerful than Sass variables.

Vague. How are they more powerful? Does that offset their downside?

> Pretty much all of the good stuff from preprocessors is going to be implemented in CSS (including conditional statements) relatively soon

It's been a decade plus and we still don't have mixins.

Re: Help choose the syntax for CSS Nesting

#137
Controversial opinions follow:

Nesting promotes bad CSS which exacerbates the problems people encounter elsewhere in CSS (like excessive specificity).

Nesting discourages paying attention to the global scope of the language and we already have many solutions to that problem for those of us who like to pretend the global scope isn't there.

Nesting grossly accentuates up front write-time benefits, whilst degrading the later read-time experience, actually making long term support harder.

Re: Help choose the syntax for CSS Nesting

#139
post #25

I'm a bit confused about the constant mention of option 3 in this article, because it seems to match none of the actual options from the original poll. The original poll offered three options: Option 1: @nest. Requires either starting a nested selector with &, or prefixing it with @nest if the & should not be at the start. Option 2: @nest restricted. Always requires starting with @nest. Option 3: Additional brackets…

[deleted]

Re: Help choose the syntax for CSS Nesting

#140

Earlier quoted context omitted.

Did you read the third paragraph in the article?

I think the question that's not answered clearly is: why can Sass parse it, but browsers can't? It says: "If they see a sequence like element:pseudo, they’ll parse the entire style rule as if it were a property: value declaration.", but why can't the parser be modified to work like Sass parser? Maybe it's obvious for someone who has deep parser knowledge, but for someone who only has a superficial knowledge, this is…

SASS only really cares about CSS compatibility with valid CSS, and won’t compile invalid CSS

Browsers handle CSS in a way that invalid CSS is ignored. This way, when you add new syntax to CSS, older parsers will ignore just the parts it doesn’t understand, and most (or all of the developer is careful) of the page will will be styled correctly

So in short, browsers have to make invalid CSS work too

Post reply on HN