Prev | Current Page 188 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"

Let??™s
run through a full calculation for the following rule:
body#home div#warning p.message {
color: red;
}
The above rule has a selector, body#home div#warning p.message, and a single
declaration, color: red;. Since this isn??™t an inline style, we start off with a 0 in
the first column, as Table 5.2 shows.
Table 5.2: Column a = 0
The Cascade, Specificity, and
Inheritance
Element Types and
Pseudo-elements
Classes, Attributes, and
Pseudo-classes
IDs Inline Style
? ? ? 0
To calculate the value for column b, we count the number of ID selectors in the
selector. In our selector, body#home div#warning p, there are two??”#home and
#warning??”thus, column b is equal to 2, as is depicted in Table 5.3.
The Ultimate CSS Reference 130
Table 5.3: Column b = 2
Element Types and
Pseudo-elements
Classes, Attributes, and
Pseudo-classes
IDs Inline Style
? ? 2 0
Next, we calculate the value for column c, counting the number of class selectors,
attribute selectors, and pseudo-classes in the selector.


Pages:
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200