Your grouped rules don??™t target that span because it??™s
descended from a div, whereas if you use the more simple and less
speci?¬? c .specialtext span approach, it is targeted.
Although this may seem like a lot to think about when you are styling
a four-line example like this, when you are working on a style
sheet that might be dozens or hundreds of lines long, you need to
keep these considerations in mind, as we do in later chapters.
HOW CSS WORKS 43
FIGURE 2.14 By using two grouped
rules, you focus your targeting to
speci?¬? c tags.
MULTIPLE CLASSES
One ?¬? nal note on classes is that you can apply multiple classes to a
single tag, like this
In this div, the span tag
may or may not be styled.
You can see that both the specialtext and the featured class names
go in the same set of quotes with a space between them, which
looks a little strange at ?¬? rst, but please refer any questions about
this to the W3C. You will see uses for multiple classes in examples in
later chapters.
Introducing IDs
IDs are written in a similar way to classes, except you use a # (hash
symbol) to indicate them in your CSS instead of the class??™s . (period)
If a paragraph is marked up with an ID, like this
This is the special text
then the corresponding contextual selector looks like this
p#specialtext {some CSS rules here}
Other than this, IDs work in the same way as classes, and everything
in our previous discussion of classes applies equally to IDs.
Pages:
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74