CSS Modularity for the Masses!
I know, I know, one more acronym we need right?
WTF?!?!
Here is a better one though ;)
.block {}
.block__element {}
.block__element--modifier {}
Syntax
Architecture
Semantic
Methodology
*Merriam-Webster
Developer semantics vs. HTML/CSS semantics
Is there really such thing as a CSS semantics??
Custom classes and ID's would lead me to believe, no.
When writing selectors, stick with developer semantics!
(shell)
Headline
Sub-headline
This is body copy. This is body copy.
(image, headline, sub-headline, copy, etc.)
Headline
Sub-headline
This is body copy. This is body copy.
(color, size, weight, etc.)
We’re not designing pages, we’re designing systems of components.
- Stephen Hay
<div class="foo">
<div class="foo__avatar">
<div class="foo__headline">
<div class="foo__headline--urgent">
<div class="foo__body-copy">
<p>Thanks for coming to my talk!</p>
</div>
</div>
</div>
</div>
</div>
.foo {
width: 400px;
height: 200px;
}
.foo__avatar {
width: 100%;
}
.foo__headline {
size: xx;
font-family: 'Some Cool Font', some-fall-back, blah;
}
.foo__headline--urgent {
color: red;
}
.foo_body-copy {
size: xx;
font-family: 'Some Cool Font', some-fall-back, blah;
}
.foo {...}
.foo__avatar {...}
.foo__headline {...}
.foo__headline--urgent {...}
.foo__body-copy {...}
Remember developer semantics?
Be specific about what the class is supposed to target.
.foo {...}
.foo__avatar {...}
.foo__headline {...}
.foo__headline--urgent {...}
.foo__body-copy {...}
Just like OOCSS
Thanks Nicole Sullivan!
<div class="foo__headline foo__headline--large foo__headline--urgent">
<p>THIS IS URGENT</p>
</div>
Causes bloat.
But it is very specific without the hassle of specificity.
Brad Frost
Atomic design is methodology for creating design systems.
Jonathan Snook
Scalable and Modular Architecture for CSS
SMACCS
Nicole Sullivan
Object framework for repeating patterns in CSS.
OOCSS
The sky is the limit!!!
CSS is awesome :)