this post was submitted on 30 Sep 2025
339 points (97.7% liked)

Programmer Humor

27113 readers
1500 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] marcos@lemmy.world 4 points 1 month ago (2 children)

are considered bad practise.

Considered by whom?

The reasons that made a bunch of people scream very loudly to not do that 20 years ago were never good enough for making generic advice and don't exist anymore.

Even more so if you use a JS library / framework or some broad browser stylesheet underneath

Learn CSS layers, use CSS layers.

Overall, if you every feel the need to write in your code "a button (behaves like a button)", it's very likely you are doing something wrong.

[–] eager_eagle@lemmy.world 2 points 1 month ago* (last edited 1 month ago)

I'm not sold on layers, they do nothing to simplify the current mess that CSS is, because they build on top of what's already out there. If CSS was built with the concept of layers, then it could probably be better. In reality, we'll always have specificity rules and IMO adding layers will just add to the complexity.

The specificity rule is not that hard to understand, I'm not sure what's the point of throwing layers in the mix. There are new CSS features I like and I see simplifying written code, but this is definitely not one of them.

[–] dohpaz42@lemmy.world 1 points 1 month ago (1 children)

Learn CSS layers, use CSS layers.

What are CSS layers? I’m legitimately curious.

[–] marcos@lemmy.world 3 points 1 month ago (1 children)

They change the precedence rules so that you can import large frameworks at will and not have them disrupt your rules or each other.

Basically, anything you apply in one layer has less precedence than what is applied on the next layers.

[–] dohpaz42@lemmy.world 2 points 1 month ago (1 children)

So I’m clear, are you referring to the @layer CSS at-rule? Or, something else?

[–] marcos@lemmy.world 2 points 1 month ago

Yes, I'm referring to the @layer rule.