In defense of CSS
Tags: css, webdev
Published: 2021-12-24 06:34:53

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.

*Side note: I asked [a question about respecting CSS on Dev.to](https://dev.to/starbist/so-how-many-of-you-respect-css-as-a-programming-language-1mj4) 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](https://www.bram.us/2021/09/15/the-future-of-css-cascade-layers-css-at-layer/), 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](https://caniuse.com/?search=aspect-ratio), 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.

* * * * *

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.

![“It is not CSS' fault that you don't know how to use it.”](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4g7420uo3fmbjwblyy4a.jpg)

If you don't write CSS often, you shouldn't be bothered. JavaScript superhero [Dan Abramov admits he doesn't know CSS](https://twitter.com/dan_abramov/status/1471227270341746700) (if you have 5 minutes, you could [watch Dan trying to center a div](https://youtu.be/XEt09iK8IXs?t=635)). 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.