
We’re excited to hear your project.
Let’s collaborate!
Would we be wrong if we stated that the very “easiness” of writing CSS code is this language's “Achilles' heel”, too? It “lures” you in, it boosts your confidence as a programmer and than... nasty surprise... your web projects gradually turn into unmanageable messes! This is why the need of building out a CSS architecture, that we can organize and structure our CSS codebases by, has rapidly gained importance in developers' community!
And where do you add that there are multiple well through-out methods for you to use for neatly and effectively structuring your CSS files! We've hand picked just 5 of them, “la crème de la creme”.
But before we go on with our CSS organizing techniques, let's “look our enemy in the eye”! Let us highlight the challenges that we're currently facing while trying to effectively managing our CSS projects:
And the list can go on.
So, now that we've pointed out the obstacles that we need to overcome when it comes to “taming” our load of CSS files into a scalable, easy to maintain CSS architecture (suitable for long-running, large projects, needless to add) let us point out to you the 5 “chaos proofing” methods:
Which stands for “Object Oriented CSS”.
The whole “philosophy” behind this CSS structuring and planning method revolves around the idea of creating pages/views by putting together multiple CSS objects! CSS objects which are independent from one another (see, the CSS's interdependence issue that we've just pointed out in our list of “drawbacks”).
And when we say “independence” from a CSS code's standpoint, we can only imply that:
And this whole “separation of concerns” driving principle has 2 major results:
“Scalable and Modular Architecture for CSS”, a style “guide” (rather than a strict framework) developed by Jonathan Snook.
Now this approach to organizing your CSS code is more than “tempting”: it promises you a lighter code “cargo” and simplified code support.
What more could you ask of a CSS organizer, right?
Moreover, this technique operates with 5 sets of rules:
Note: take the SMACSS approach as a guideline rather than as a strict method, or a set of rigid “rules”. As a web developer who'll use this method to build a well-structured, maintainable CSS architecture, you'll still be free to use your own namespaces for your class categories, to display them to your liking and so on. The only “common sense” rule is that of documenting your CSS code, so that all the other developers in your team should easily follow you along.
But this “rule” stands irrespective of the CSS structuring approach that you might decide to adopt, right?
… or “Block Element Modifier”, if you prefer, developed at Yandex!
Expect it to be more prescriptive than SMACSS (for instance). BEM is more than just a set of basic guidelines: it delivers a strict method for you to structure your CSS classes into independent modules!
And speaking of this method, although you'll find multiple variations on it, the basic structure looks like this:
.block {}
.block__element {}
.block--modifier {}
.block__element--modifier {}
It's only just “fair” that we presented each one of this structure's components right?
Key Advantages to Using the BEM Method as a “Backbone” for your CSS Architecture:
… or maybe you prefer “Functional CSS” instead?
As for this CSS “organizer's” philosophy, so to say, we could formulate it like this: creating one separate, single-purpose class for each and every reusable property, while naming it according to its visual function!
The undeniable advantages of such an approach to organizing your CSS code are:
Yet, this method does come with its own flaws, too. Here are some of the most “painful” ones:
Note: Atomic CSS has “succeeded” to split developers' community into 2 major groups: those that keep highlighting this methodology's major flaws and those that, on the contrary, qualify specifically these flaws as benefits instead:
Harry Roberts' “Inverted Triangle CSS” implies, as the name suggests: visualizing and structuring your project as a triangle. An upside-down one!
This triangle-shaped structure would include the following “layers” of CSS code:
Practically, the IRCSS technique “constrains” you to order your CSS codebase not by the usual human-oriented patterns, but by those metrics defined by the programming language (along with its particularities) itself!
Ordered this way, your code will get better “understood” and “exploited by both browsers and by the specific design of the programming language itself. It will no longer get organized by how a person thinks, but rather adapted to the language's own features and to the way browsers perceive it.
This way, your ITCSS-based CSS architecture will end up to be:
... instead of an “untamed mess”!
Which one of the above presented 5 methods better suits your team's coding style? Your current project's specific needs and requirements? Go for the one that you find more suitable for your own team's specific workflow, coding style and for your web project's particularities and get your own “unmanageable CSS mess” ideally structured, too!
We’re excited to hear your project.
Let’s collaborate!