DEV Community

Discussion on: Why is CSS Hated On?

Collapse
 
latobibor profile image
András Tóth • Edited

In my own very subjective experience CSS gets a lot of roasting because of its early days. In the early 2000s there were many browser engines with half-baked implementation of the standards.

You built up your site in Internet Explorer 6? How cute 🤩. Now it looks like crap in Firefox... One browser had default margins and paddings, the other didn't, things that were not exactly specified by the standards (like negative margin values) got implemented in widely different ways and so on.

With the unreliability of the effects of the declarations, it soon became a running joke to struggle with CSS, and people often felt it is witchcraft instead of engineering. Witchcraft in the sense that you have to inherit a recipe for a concoction from somebody as you have no chance figuring it out yourself: "Well, you know, what you wrote is OK in this browser but now just copy-paste this block to make it work in everything else."

Though language itself was mostly logical (there are still issues coming from the huge vocabulary you need to learn), but its support was not; you had to learn a ton of non-reusable workarounds, that made it unpopular. (I wrote about non-reusable knowledge: it is a must to be an effective engineer, but you hate gaining every bit of that knowledge...)

That was one source of unpopularity. The another one was a missing dimension of freedom. CSS was intended to describe documents in an effective, overridable way: with a couple of great rules you could style a huge amount of documents with very little code.

But the same thing did not work when you had multiple teams working in a big application. When one team had its implemented its own notification-dot and then another team their own notification-dot declarations, the resulting conflict meant that things were breaking without warning. The language itself did not have a trivial, explicit way to express isolation from other's code (with the advent of CSS layers, we might have this ability).

And in a big corporation isolation is important thing as people does not have the time to ask every team's every developer if it OK, that they will have a .notification-dot class.

Then people started "fixing" CSS by inventing abominations that went against the nature of cascade and caching, like forcing CSS to be created during JS runtime to be tightly linked to the one component it was used for. This essentially robbed the browser engine to effectively cache stylesheets and speed up rendering.

But in 2022 the standard got adopted pretty well, most browser engines are gone and there are very good training materials. So it is time to embrace the cascade and write smart, fluid designs. (Tip: Every Layout -> one of my favorite new sources).