An Introduction To Object Oriented CSS (OOCSS)

An Introduction To Object Oriented CSS (OOCSS)

Have you ever heard the phrase “Content is King”? Being a Web developer, and therefore having a job that’s often linked to content creation, it’s likely you have. It’s a fairly overused but true statement about what draws visitors to a site.

[…]

Unfortunately, CSS seems to get somewhat overlooked in this area while many developers (for good reason) focus largely on JavaScript performance and other areas9.

[…]

As described on the OOCSS GitHub repo’s Wiki page10, OOCSS is based on two main principles.

[…]

Before applying OOCSS principles, you might have CSS that looks like this:

[…]

The second principle described on the OOCSS GitHub wiki page is the separation of containers from their content. To illustrate why this is important, take the following CSS:

[…]

With this type of forethought, it’s possible to create entire pages while coding very little CSS. Any existing CSS modules can serve as a basis for all new pages, and any new CSS will be minimal. In some cases you might even be able to create a new fully-styled page without coding a single line of CSS.

[…]

But here are some things you might want to start doing to help you get into an OOCSS mode of thinking:

[…]