Prev | Current Page 85 | Next

Charles Wyke-Smith

"Stylin' with CSS: A Designer's Guide 2nd Edition"


4. Read the result as a three-digit number. (It??™s not really a threedigit
number; it??™s just that in most cases, reading the result as a
three-digit number works. Just understand that you can end up
with something like 0-1-12, and 0-2-0 is still more speci?¬? c.)
So let??™s look at the speci?¬? city of these examples
P
p.largetext
p#largetext
body p#largetext
body p#largetext ul.mylist
body p#largetext ul.mylist li
Each example is a higher speci?¬? city than the previous one.
Cascade Rule 4: Sort by order. If two rules have exactly the same
weight, the one furthest down the Cascade overrides.
And that, dear reader, is the Cascade and, yes, it is somewhat hard
to understand, especially if you have not yet had much experience
with CSS, but my simpli?¬? ed version of the Cascade rules (see the
sidebar earlier in this chapter) applies in about 98 percent of cases.
If you ?¬? nd that something isn??™t behaving the way you want when
you??™re using this simpli?¬? ed version, refer to the above rules.
0 - 0 - 1 speci?¬? city=1
0 - 1 - 1 speci?¬? city=11
1 - 0 - 1 speci?¬? city=101
1 - 0 - 2 speci?¬? city=102
1 - 1 - 3 speci?¬? city=113
1 - 1 - 4 speci?¬? city=114
Speci?¬? city is more important than
order, so a more speci?¬? c rule high up
the Cascade overrides a less speci?¬? c
one further down.
STYLIN??™ WITH CSS - CHAPTER 2 60
Rule Declarations
So far I??™ve focused on how you use CSS rule selectors to target tags,
but you haven??™t yet looked much at the other half of a CSS rule, the
declaration.


Pages:
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97