Hacker News new | ask | show | jobs
by paczki 44 days ago
Working with modern CSS is such a joy, and increasingly as time goes on I'm replacing huge chunks of JS with CSS which is a little boon in itself. Honestly, my only complaint is how long I have to actually wait to use new features.

Nesting and @layers make maintaining CSS drastically easier than it once was as well.

2 comments

I agree. And I don't even use layers yet. I keep specificity roughly in mind and narrow my selectors using nesting properly to only affect what I want the rules to style. Do I make mistakes? Sure, but they are easy to fix. Make selectors specific enough and think about whether the rule you are writing is something general or just something for this one component on the page, and it is eeeeasy to not make a mess these days.
How is that? I also like CSS, but when I looked at the @layers spec I didn't see any immediate use case.
Layers is for organization.

You can always have different files for different things but without @layers you'll bump into specificity issues. You'd also have to arrange your imports correctly or you spend countless hours on "why is this style being applied and not that one?".

It's what makes modular CSS (with cascade) actually possible.

Honestly, I really never had specificity issues (apart from some third party CSS adding styling with high specificity)