New Perspectives On Web Design

(C. Jardin) #1

CHAPTER 1 Modern CSS Architecture and Front-End Development


Machines do not discriminate at all against the classes you use because
they do not understand them; it is merely their job to match them.

SeManTiCS vS. SenSibleneSS
When most people talk about semantics, what they’re really referring to
is sensibleness. As we have ascertained, classes and IDs have no bearing on
semantics whatsoever. A class of red is neither semantic nor not semantic,
because classes are not found on the semantic spectrum. A class of red,
however, is probably quite ill-advised.
When choosing names for your classes, forget about the idea of seman-
tics and look more at their longevity. How long will this name continue to
make sense? How long will it stay relevant? How much sense will it make
in six months?
Taking the .red example further, it is clear to see why this is an unwise
name for a class. Imagine you’re working on an e-commerce site and you
need to style a price differently because it is a special offer, like so:

<strong class="red">$99.99</strong>
.red {
color: red;
}

If that style just happens to involve the color red then a class and selec-
tor of red might be used, perhaps inadvisably. If, for whatever reason, you
want to change all special offer prices to be blue then you’d end up with
something like this:
<strong class="red">$99.99</strong>
.red {
color: blue;
}
Free download pdf