Calculating CSS 2.1 selector specificity

When an element is matched by the selectors of several CSS rules, the most specific selector wins and the declarations in the corresponding rule are applied. That makes sense, but sometimes figuring out which selector is most specific can be tricky. Fortunately reading Andy Clarke's CSS: Specificity Wars and Molly E. Holzschlag's CSS2 and CSS2.1 Specificity Clarified will help you understand how selector specificity works and how to calculate it.

Posted on October 8, 2005 in Quicklinks