In defense of CSS

Category: Blog

Tagged: css

Published at:

I am here to take a stand and defend CSS, my most favorite programming language. I don't care if it is a proper programming language or not, and I don't think the authors cared, too. However, I do care about its beauty, power, simplicity, and complexity.

In defense of CSS.

I asked a question about respecting CSS on Dev.to earlier this year. Unfortunately, the discussion escalated and went in the entirely wrong direction.

If you started to learn CSS in the last couple of years, consider yourself lucky. I have been kind of lucky, too, and I have avoided table layouts, but I had to deal with float layout. Today, CSS is much nicer and friendlier, and you don't need to use too many "hacks." No matter what, I always loved it.


The thing with CSS is that you need it, whether you love it or not. Cascade, stacking context, box models, these could be tough and abstract, but you need these to be your friends, not enemies. It is easy to jump straight to frameworks. Bootstrap, Tailwind, Bulma, whatever, these are great, but it comes down to mastering the basics. I have been the loudest spokesman of Bootstrap for years, but I had to master the CSS basics anyway. Although I rarely use frameworks these days, I am still curious, exploring new and shiny players here and then. There is nothing wrong with broadening your horizons, as long as you know the basics.


CSS is moving fast. New features emerge every year, making our lives both harder and easier. Sometimes a new feature adds more complexity. Take Cascade Layers, for example. It will be hard to master the concept of controlling the cascade. But, sometimes, a new feature provides a more straightforward solution. Take the aspect-ratio property (which is finally supported by all major browsers, btw). It feels so good not to use the padding hack anymore. Whether a feature is complex or not, the important thing is that CSS is moving in the right direction.


Just like you need CSS for web-based projects, you need JavaScript as well. I am not a JavaScript developer, but I use JavaScript daily. I know enough to get by and to avoid mistakes. When es6 was introduced, I was afraid of it. I did not even master the es5, and the new JavaScript version was out. I tried to ignore it, but I could not do it forever. So I had to learn it and understand how and when to use new features. Eventually, it made my life easier, but the learning path was not straightforward.

What I did not do was complain all over the Internet about it. Instead, I got my hands dirty and wrote a tone of code until it made sense to me. I did not expect to do it without spilling blood, sweat, and tears. It doesn't work that way.


And remember, it is not CSS' fault that you don't know how to use it.

Before you decide to write something terrible about CSS, try to understand what is going on first. Mastering CSS is all about understanding the context and concept and everything in between. It is not CSS' fault that you don't know how to use it.

If you don't write CSS often, you shouldn't be bothered. JavaScript superhero Dan Abramov admits he doesn't know CSS (if you have 5 minutes, you could watch Dan trying to center a div). So please don't rant about CSS if you're not using it regularly. Everything is hard when you don't use it. However, if you use CSS daily, you better start learning CSS and get better at it.