Prev | Current Page 185 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"

The result of this calculation takes the form
of four comma-separated values, a,b,c,d,9 where the values in column ???a??? are the
most important and those in column ???d??? are least important. A selector??™s specificity
is calculated as follows:
?–  To calculate a, count 1 if the declaration is from a style attribute rather than a
rule with a selector (an inline style), 0 otherwise.
?–  To calculate b, count the number of ID attributes in the selector.
?–  To calculate c, count the number of other attributes and pseudo-classes in the
selector.
8 http://www.w3.org/TR/CSS21/cascade.html#specificity
9 This is different from the CSS1 specification, in which specificity took the form of a number score,
as explained at http://www.w3.org/TR/CSS1#cascading-order.
The Cascade, Specificity, and
Inheritance
The Ultimate CSS Reference 128
?–  To calculate d, count the number of element names and pseudo-elements in the
selector.
The result of counting these elements is not a score, but a matrix of values that can
be compared column by column.


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