Prev | Current Page 173 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"


In step three, declarations are sorted on the basis of the specificity of their selectors.
The specificity of a selector is represented by four comma-separated values, and is
calculated by counting the occurrences of different elements in the selector. For
example, inline styles have the highest specificity, while element type selectors
have the lowest specificity. A complete explanation of the specificity calculation
requires more space than is available here; read more about it in Specificity (p. 126).
The declaration that has the selector with the highest specificity is applied to the
element. However, if two or more declarations that set the same property for the
same element also have the same levels of priority and specificity, the CSS cascade
proceeds to step four.
Step four is the simplest step and makes the final determination about which
declaration to apply to the element without ambiguity. The declaration that??™s
specified last is the one that??™s applied to the element??”a process that??™s often
expressed as the latter declaration overwriting the former.


Pages:
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185