Trying to help CSS haters to see the world from the 'float: right' side

Posted on
Tags: CSS , motivation

Do you like to read articles about CSS? I do! Then see these kind of comments:

ugly, bloated CSS files, hard to name classes

And I would like to provide additional context to it.

The ugly

That is the responsibility of the developer. You can make it ugly or put beautiful plants 🌷 to it. That ugly thing is the way you feel (opinion). This helps you to improve because you start to see the “ugly”.

Look at BEM (or others): it looks ugly to some, but it works. It is about functionality with a compromise on design (look).

The bloated

These are not as bad as some people think. Compressing it will do the job quite well. If you want to make it perfect, then just look at how all the other companies are doing it. Not even <put any tech company name here> is doing it perfectly. If you want it to be perfect, then you need a system for it.

And that is a lot harder than it looks like.

In any case, you should not do one thing: Don’t use a class name on your HTML element that is not declared anywhere. In this case the browser will need to go over all fruits and flowers you planted in your CSS file. Then the browser will let you know by a performance issue, that you just made it angry, because it might need to look for it again next time. It might be there, in that ‘ugly’ file, somewhere. Think about it like this: the browser will hate you.

The names

OK, HTML might have less tag elements than your CSS having class names, and most of the time you don’t use it a lot. But what about JavaScript?

I read in multiple articles where HTML, CSS and JavaScript were put in one sentence or paragraph and CSS looked like the worst of them because of this opinion.

I am not sure, but I use a lot more variable names in JavaScript than in all my CSS files. Add some TypeScript and sane people start to think you are a genius, a magician, or simply crazy.

Honestly: that would make me proud of myself and get motivated at the same time.

Finding names can be hard, but don’t give up! With great experience you have great responsibility to name your kids dog code.

Conclusion

There is no golden egg, just compromises for the best tool to finish the product. It takes a collective effort in our line of work to make it possible.

Don’t take it too hard. I hated CSS too and tried to make it usable. After years it still is hard if it gets out of hand. But time showed: we are improving, not alone but together.

There are the guys who wrote table layouts, ranted about it, made workarounds, ranted more, until others improved the software to use CSS better. Not perfect, but better. Now we have so much power to use because we worked together. Yes, constructive ranting is also feedback. And the wheel starts turning again.

It gets better with time. 🥚