Cargo Cult CSS

Case against the modularization of CSS: Cargo Cult CSS:

Selectors should communicate useful information to developers. The purpose is the same but a contextual selector is far more informative to the developer than a class selector, as it communicates context. It’s a lot easier to understand the purpose behind a rule if the selector tells you that it only applies to elements within a certain scope.

Must admit that I still have to contain myself selector-wise — I used to write heavy selectors back in the day — when applying concepts like SMACCS (which in fact has changed how I write CSS nowadays), as some of the stuff such as <article class="news news-breaking"> can be achieved by using a preprocessor (here @extend).

I guess the solution can be found somewhere in between, although my solution might not even be your solution. As Jeremy Keith once put it: it depends.

In favor of the modularization of CSS, be sure to read CSS Architecture.

The bottom line is that whatever you do to organize your code, make sure you judge your methods by whether or not they actually help make your development easier and more maintainable in the long term.

Cargo Cult CSS →
CSS Architecture →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.