Calculating CSS selectors’ specificity

CSS Monday, March 23rd, 2009 @ 11:11 | Follow comments

(This is actually old news, but maybe some people out there has missed it.)

Sometimes, developers get confused when it comes to understanding why a certain selector overrides another. I guess the standard ways of solving it is reordering the selectors in the CSS or using ID selectors instead (as they’re well known to override most other selectors). But there’s of course plenty of logic to why certain selectors override others, and the reasons can be found in the official W3C documentation.

It’ll help you a lot in creating a sold and good structure in you CSS documents. Probably a good idea to keep the list bookmarked until you remember the rules, though… :-)

Share article with others:

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • LinkedIn
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Buzz

Leave a Reply