Prev | Current Page 187 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"


The first step is to calculate the value for column a, which we??™ve done in Table 5.1.
If the style rule is specified within the element??™s HTML style attribute, a should
equal 1; otherwise, it should equal 0. In fact, this is the only case where there is a
value in column a.
129 The Cascade, Specificity, and Inheritance
Table 5.1: Inline Style: Column a = 1
Element Types and
Pseudo-elements
Classes, Attributes, and
Pseudo-classes
IDs Inline Style
0 0 0 1
As you can see, an inline style rule will always have a specificity of 1,0,0,0??”the
highest level of specificity. Here??™s an example of such a style rule:

Red Text


This is one of the reasons why inline styles should be avoided. As inline style rules
always have the highest specificity, the only way to overwrite them within the CSS
cascade is to use the !important statement (p. 124) on the relevant declarations??”an
approach that creates a maintenance nightmare.
For rules other than inline styles, we need to calculate columns b, c, and d.


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