CSS Frameworks are like sex...

Religion is like a penis
Religion is like a penis [Original Source]

Since I read it a couple of years ago, this quote has really stuck with me.

With recent front-end twitter conversation turning to CSS frameworks, I went on a roller coaster of emotions but eventually settled on the above to sum up how I felt about the ordeal. Before we settle once more, let me take you on the journey I travelled.

Don’t make a CSS framework #

We don’t need another framework. We don’t need another Github repo gaining thousands of stars (or not) but no-one actually uses it.

There are hundreds (if not thousands) of CSS frameworks out there that do the job perfectly fine. At the end of the day it is just CSS - how different can it be to yours? If you need help picking one, there is this excellent comparison website to help you choose. If that’s not enough, you can google and sift through the (at time of writing) 554,000 results.

So with all those out there, why would you need to make a new one? Just pick an existing one and be done with it.

You should make a CSS framework #

Standard
XKCD - [Original Source]

Rather than use one of the myriad of CSS frameworks available, you should make your own. Yes, I know there are thousands available, so one more won’t hurt. The one that makes this one better, the one that makes this the ultimate, is that it is yours. It is made for you, by you and used on your project(s).

Say you decided to use an existing framework, you can spend more time choosing, trying and picking then actually building the site. Then there is the post-build updates. If you’re on Bootstrap 2, do you update to 3? or 4?

The other thing about existing CSS frameworks is that every week there is a new, better, smaller, faster, more responsive, less rigid, modular one. Do you stick with your old, slow out-of-date one or do you spend a day learning the new one?

If you had your own one, you can make sure all your projects are kept to date. You can make sure the documentation is there and most importantly, you can make sure there is no bloat. New CSS feature you want to use? Roll it into your own framework and it’s available everywhere - no hunting round for an alternative one that features it.

You will also find your CSS framework might fix a flaw that every other framework has, but might have a gaping hole you never notice.

There is nothing that compares to the knowledge learnt while building a CSS framework. Especially that feeling when you’ve used it for the first time and then come to use it again and nothing works. It’s a perfect opportunity to refactor, recode & reuse.

The next step is to document - this is another great learning point. Not writing what you’ve got but explaining why it’s done that way. You’ll find yourself rewriting bits all over again.

By all means upload it to Github & tweet about it but remember, this framework is for you.

Conclusion #

So, really:

A CSS framework is like a penis. It's fine to have one and it's fine to be proud of it, but please don't whip it out in public and start waving it around... and PLEASE don't try to shove it down my child's throat.

However, this analogy doesn’t work quite as well with CSS frameworks, so i’ve come up with one of my own:

Building a CSS framework is like having sex: everyone should at least do it once but once you have, you don’t need to brag about it. Everyone thinks theirs is the best and everyone is embarrassed by their first attempt.

Or this one, submitted by Simon:

Having a CSS framework is like learning to ride a bike. You start off unsure of yourself, need a helping handing before being brave enough to go solo. But remember, just because you can ride a bike doesn't mean you'll win a stage of the Tour de France.