CSS sucks because we don't bother learning it.

Try learning and you won't complain anymore

Every time I hear someone complaining about how much CSS sucks, I have one question: Did you ever learn CSS? The words want to burst out of my lips but I stay silent and keep to myself. When I was much greener in this field, I used to ask the question. What I noticed is that no one was willing to change their mind. CSS sucked, it was designed by some terrible people, and now we have no choice but to maintain it. The reality is, you can say that about pretty much every programming language. Though people like to point out that CSS is not one. But do we ever set time to learn CSS?

When programmers build complex apps that communicate with dozens of other services, they forget one thing. Nowhere in the design, they think about how the result of their work will be presented to a user. In the age of microservices, it becomes ever more difficult for one person to know how all the parts connect together. Being a backend developer takes experience and dedication. You master the programming language, you study your employers architecture, you learn from those who paved the path before you. Every programmer worth their salt agrees with Peter Norvig's essay Teach Yourself programming in Ten Years.

It's inconceivable that you can learn a programming language and be effective in it in a short time. There is much more to programming than syntax. Programming is writing, it is problem solving, it is art. You build a mental model of a problem, break it into smaller pieces, and translate it into a language a computer can understand. It takes years to become really good at it.

But for some reason, we finish all parts of our application, then we start learning and writing CSS at the same time. Like a college student going through a test, saving the easy questions for last. Only, when they finally get to those questions, they are short on time and realize that it's not as easy as they thought.

CSS may not be a programming language per se, but that doesn't mean you can learn it in a day. You can learn the syntax just like you can learn the cool parts of JavaScript in a day. But using CSS to solve a design problem demands just as much planning and experience as you would with any other task.

A lot of people bring up how it was nearly impossible to align a div to the center in CSS 2. Many times, they will have an insane HTML structure that makes it impossible to do so. They will spend hours on google looking for ways to do it, and end up with a hack that works as long as you don't touch anything else on the page. With CSS 3, they'll use the same bad HTML structure and use flex box to auto-magically align it. It becomes a pain for the next person to maintain. But in their defense, they hated maintaining it too.

Imagine building an application by googling every single line of code. You end up with something that probably works as long as the circumstances don't change. Updating the application becomes a nightmare, it makes you hate programming. That's how and why people hate CSS. They never take the time to learn it. They slap a framework like bootstrap on top of their project, they use !important, they use position: absolute, they sprinkle a bunch of classes name in their HTML. They have no idea what they are doing.

Is CSS perfect? No, not at all. They could have come up with something better than margin: 0 auto to center a block element in CSS 2. They could have come up with something better than the content property in pseudo selectors. But even when I look at those issues, once I understand the behavior, I can plan how I use it.

For example, I often advise never to use position: absolute. Then people ask me, why are you using it in your code then? My answer is, never use it, so you'll know when to use it. When you give someone the ability to use position absolute, they'll align the entire page with it. They'll only notice things are broken when they use a different screen.

If you hate CSS, there are thousands of places online where you can learn it. Follow an actual course with an experienced instructor. Learn to design a page using CSS. It's much easier than your traditional programming language, but you can't understand it unless you learn it first.


Comments

There are no comments added yet.

Let's hear your thoughts

For my eyes only