Prev | Current Page 186 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"

As an example, consider the following rule which
contains an element type selector from the previous example:
p {
color: black;
background-color: white;
}
If we try to work out the specificity of the above selector on the basis of the specificity
formula, we arrive at a result that looks like 0,0,0,1, as it has one element name.
As we said before, this is not a number but four comma-separated values, where
the values in column a (inline styles) are the most important, and those in column
d (element names and pseudo-elements) are the least important. When comparing
selectors to determine which has the highest specificity, look from left to right, and
compare the highest value in each column. So a value in column b will override
values in columns c and d, no matter what they might be. As such, specificity of
0,1,0,0 would be greater than one of 0,0,10,10.
Specificity Step by Step
Let??™s try and break down each part of the calculation procedure so that it??™s more
understandable.


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