UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
Modern CSS makes it easy
to style components,
such as this one.
However, not everyone writes
CSS the same way.
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
UIIUIUIN UIIU
UIUNUN INU UIN
Slide 3
Slide 3 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
HTML makes it
intuitive to write
classes and nest them
properly.
article
Slide 4
Slide 4 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
HTML makes it
intuitive to write
classes and nest them
properly.
article
div.image
Slide 5
Slide 5 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
HTML makes it
intuitive to write
classes and nest them
properly.
article
div.heading
div.image
Slide 6
Slide 6 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
HTML makes it
intuitive to write
classes and nest them
properly.
article
div.heading
div.description
div.image
Slide 7
Slide 7 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
HTML makes it
intuitive to write
classes and nest them
properly.
article
div.heading
div.description
div.actions
div.image
Slide 8
Slide 8 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
HTML makes it
intuitive to write
classes and nest them
properly.
article
div.heading
div.description
div.actions
div.image
img
Slide 9
Slide 9 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
HTML makes it
intuitive to write
classes and nest them
properly.
article
div.heading
div.description
div.actions
div.image
img
h2.title
h2.description
Slide 10
Slide 10 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
HTML makes it
intuitive to write
classes and nest them
properly.
article
div.heading
div.description
div.actions
div.image
img
h2.title
h2.description
p
Slide 11
Slide 11 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
HTML makes it
intuitive to write
classes and nest them
properly.
article
div.heading
div.description
div.actions
div.image
img
h2.title
h2.description
p
a.button
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
article
div.image
img
div.heading
h2.title
h2.description
div.description
p
div.actions
a.button
"Semantic"
The naïve
approach
Slide 20
Slide 20 text
This approach makes you prone to have very complicated CSS.
Slide 21
Slide 21 text
CSS feels complicated.
REALLY:
Slide 22
Slide 22 text
It doesn't have to.
TRUTH:
Slide 23
Slide 23 text
@rstacruz
Rico Sta. Cruz
Slide 24
Slide 24 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
.photo-card {
.photo {
img { ... }
}
.text {
.heading {
.title { ... }
.subtitle { ... }
}
.description {
p { ... }
}
.action {
.btn { ... }
}
}
}
Over-nesting is a
common problem
with this approach,
though. CSS becomes
hard to read.
Slide 25
Slide 25 text
Block-element-modifier
http://bem.info
Slide 26
Slide 26 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
BEM
Makes this a little easier.
.photo_card
.photo_card--photo
.photo_card--heading
.photo_card--subheading
.photo_card--description
.photo_card--action
Slide 27
Slide 27 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
BEM
Makes this a little easier.
Block Element
.photo_card
.photo_card--photo
.photo_card--heading
.photo_card--subheading
.photo_card--description
.photo_card--action
Slide 28
Slide 28 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
.photo_card {
&--photo {
...
}
&--heading {
...
}
&--subheading {
...
}
&--description {
...
}
&--action {
...
}
}
BEM
Makes this a little easier.
Slide 29
Slide 29 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
It comes at the price
of dirtier markup.
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
Bootstrap has its own
convention in class
names.
.panel
.panel-head
.panel-body
.btn
.btn-primary
.btn-small
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
UIIUIUIN UIIU
UIUNUN INU UIN
Slide 32
Slide 32 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
.photo-card-image
.photo-card-title
.photo-card-subtitle
.photo-card-description
.photo-card-action
Bootstrap
would probably
suggest something
like this.
Slide 33
Slide 33 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
Bootstrap's approach
is almost equivalent to
BEM, anyway.
.photo-card
.photo-card-photo
.photo-card-heading
.photo-card-subheading
.photo-card-description
.photo-card-action
Slide 34
Slide 34 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
Bootstrap's approach
is almost equivalent to
BEM, anyway.
Block Element
.photo-card
.photo-card-photo
.photo-card-heading
.photo-card-subheading
.photo-card-description
.photo-card-action
Slide 35
Slide 35 text
Naïve BEM
Cleanliness
(or Bootstrap)
Slide 36
Slide 36 text
Naïve BEM
Cleanliness
CSS
cleanliness
(or Bootstrap)
Slide 37
Slide 37 text
Naïve BEM
Cleanliness
Markup
cleanliness
CSS
cleanliness
(or Bootstrap)
Slide 38
Slide 38 text
Naïve BEM
Cleanliness
Markup
cleanliness
CSS
cleanliness
?
Slide 39
Slide 39 text
What if...
there is a way to make a
compromise between
both?
Slide 40
Slide 40 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
.photo-card
What if...
there's a way to keep this
semantic structure, yet have
clean CSS?
Slide 41
Slide 41 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
.photo-card
.image What if...
there's a way to keep this
semantic structure, yet have
clean CSS?
Slide 42
Slide 42 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
.photo-card
.heading
.image What if...
there's a way to keep this
semantic structure, yet have
clean CSS?
Slide 43
Slide 43 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
.photo-card
.heading
.description
.image What if...
there's a way to keep this
semantic structure, yet have
clean CSS?
Slide 44
Slide 44 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
.photo-card
.heading
.description
.actions
.image What if...
there's a way to keep this
semantic structure, yet have
clean CSS?
Slide 45
Slide 45 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
.photo-card
.heading
.description
.actions
.image
.title
.description
What if...
there's a way to keep this
semantic structure, yet have
clean CSS?
Slide 46
Slide 46 text
UIIUIUIN UIIUNIUN
UIUNUN INU UINUIU
.photo-card
.heading
.description
.actions
.image
.title
.description
.button
What if...
there's a way to keep this
semantic structure, yet have
clean CSS?
Slide 47
Slide 47 text
rscss
Reasonable System
for CSS Stylesheet
Structure
http://rscss.io