How to Write Object Oriented CSS

Tetris video game cover

* Image taken from the cover art of the world-famous Tetris video game.

Objects Shmobjects.

The first time I heard about Object Oriented CSS was from a tutorial on NetTuts. At the time, I viewed OOCSS as just another random framework somebody was imposing on the web community. I had not given it much thought since then, until I listened to Nicole Sullivan‘s interview on The Big Web Show. She’s a CSS pro who started and the open-source OOCSS project on github. Nicole has been hired by mega-sites like Facebook to optimize their CSS files. FACEBOOK! That must have been insane!


Having spent a chunk of the last 4 years of my life learning and working with CSS on a daily basis, I was intrigued to hear the thoughts of an elite CSS Ninja. Half way through the interview I found myself inspired to become an Object Oriented CSS-er.

I started browsing the Google tubes and found a nifty presentation created by Nicole: The Fast and the Fabulous

If you didn’t have time to click through the slideshow here is a super tiny break down:

Two main principles

  1. Separate structure and skin
  2. Separate container and content

Applying these principles creates efficient CSS code. This means cleaner smaller CSS files that load faster.

What does it look like?

This basic structure is very flexible. By adding classes you can “extend” the object class to fit each scenario the design requires. For example:

[html]<div class=”object simple half”> …[/html]

Extending the object class is faster to write and to load.

I’m extremely guilty of writing overly specific CSS, thinking that everything has to have its own ID. Trying to be too semantic, I guess. I’ve confused myself by listening to too many different theories about how to structure your HTML and how to reference selectors in your CSS files.

I’m realizing that all I’ve needed was a little objectivity.


9 responses to “How to Write Object Oriented CSS”

  1. How to Write Object Oriented CSS | | Graphic … | My Blog

    […] is the original post: How to Write Object Oriented CSS | | Graphic … This entry was posted on Friday, July 16th, 2010 at 1:30 pm and is filed under Uncategorized. […]

  2. Chase Bowers Avatar
    Chase Bowers

    Interesting. You've inspired me to learn more…

  3. parisvega Avatar

    Glad to hear it! Now I just need to practice what I preach and re-write the CSS for this website using OOCSS.

  4. This post is amazing, I'm thinking of printing it and wallpapering my entire home with this eternal wisdom.

  5. parisvega Avatar

    Please do. It may change your life.

  6. Conor Maguire’s Blog

    […] doing it like an idiot but in my defense so has everyone else. I went through the slide show here: and have downloaded her (Nicole Sullivan) framework ( to examine exactly […]

  7. Jessebreuer Avatar

    All of the principles sound great but almost no examples. I came across this concept, and Nicole’s ideas, several months ago, and thought the same thing then. Why not a tutorial, maybe some examples?

    1. I had the same problem. The only example I could find is the one she references about her experience working with Facebook. Since then I’ve attempted to apply OOCSS principles and use the OOCSS framework on a big project. The results were mixed. Some of the basic elements of the framework were great at saving time writing code & space in the files. However, there was a bit of chaos when it came to figuring out when to use a “module” how to organize module skins. In the end, I regretted using the framework on that specific project because it actually took much longer to write the code than normal. Granted, much of my time was spent studying OOCSS and trying to gain an understanding of the principles involved. A more savvy coder would probably have more success than myself.

    2. I agree. I tried implementing the OOCSS framework she has on github for a project. I’m mixed about the results. The grid system is awesome and saves loads of time. The modules are a little crazy.

Leave a Reply

Your email address will not be published. Required fields are marked *