Prev | Current Page 183 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"

Because one of those rules has an element type selector p, it??™s
guaranteed that two or more rules will apply to the same p element, and because
they all contain a color property declaration, the user agent needs a way to
determine which of the declarations should be applied. What will the final color
value be for the p element?
The simple answer is that the more specific selector??™s declaration will take
precedence. The user agent calculates each selector??™s specificity so that a comparison
can be made, and resolves the deadlock by choosing the declaration whose selector
has the highest specificity.
127 The Cascade, Specificity, and Inheritance
Calculating Specificity
Here??™s a simplified description of the process by which the specificity of the selectors
of two or more declarations is compared:
1. If one declaration is from a style attribute, rather than a rule with a selector (an
inline style), it has the highest specificity. If none of the declarations are inline,
proceed to step two.


Pages:
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195