4 ms·
Scoping and nesting are two things that would solve 99% of problems when it comes to organising CSS (and components). They should definitely be on the browser l
by dmitriid 4y ago
Scoping and nesting are two things that would solve 99% of problems when it comes to organising CSS (and components). They should definitely be on the browser level and not "solved by preprocessors".
- tannhaeuser 4y agoI disagree. Given the enormous complexity browsers have aggregated already, we should strive to make browsers "player apps" (like MP3 players): a relatively simple front end with huge versatility in server apps and back ends, rather than, like, everything for everybody. I'm aware that ship has sailed a long time ago, but piling ever more not-so-well-motivated stuff onto browsers just means the next generation has to start over with a clean slate; actually I think this is inevitable already. CSS nesting is clearly serving the use case of components in web apps, as opposed to mere content-driven web sites. IMO a sensible approach would be to give web app developers powerful ways to tie into rendering and layout programmatically (a la Houdini API) when those apps will require JavaScript, and in many cases use CSS-in-JS anyway, rather than burden browser cores with ever more questionable CSS features. "Would solve 99% of use cases" also sounds like famous last words ;)
- dmitriid 4y ago> a relatively simple front end with huge versatility in server apps and back ends Define "relatively simple"? Nesting and scoping in CSS don't make frontend any more complex. CSS has had problems with it's flat top-level structure since the very beginning of its existence. Approaches like BEM didn't appear out of thin air. > CSS nesting is clearly serving the use case of components in web apps, as opposed to mere content-driven web sites. Even a content-driven web site has a plethora of repeating and/or complex elements that are a pain to define and maintain. > Would solve 99% of use cases" also sounds like famous last words Google has poured hundreds of millions of dollars into web components whose primary use case (that is, what they are being used for in reality) could've been solved by scoping and nesting. Same goes for all the CSS-in-JS abominations.
- tambourine_man 4y agoAFAIK, this is just syntactic sugar. A shortcut. It’s not scoping in the inheritance sense. The C in CSS is for cascading. Inheriting is the natural way to be for CSS
- dmitriid 4y agoCasacading !== inheritance. These are very different things. I wish we had inheritance (or traits) in CSS.
- tambourine_man 4y agoWell tell me the difference then. We have cascading inheritance, that’s what CSS is all about. Unless we’re using different definitions of the term
- dmitriid 4y agoCasacading alpplies to all elements in the cascade. Whether you want it or not. At the same time it's impossible to say "hey, I want to inherit from that particular style", and not have the cascade apply to it. For example, I want a button and I don't want anything in the hierarchy above overriding its borders, or colors, or fonts, or...
- tambourine_man 4y agoOh, I see. Arbitrary non hierarchical opt-in inheritance. Or perhaps a cascading inheritance opt-out, and you could add classes back as you please. That would be cool. Not sure how it would impact browser parsing and drawing, but it sure would be useful.