Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nesting is not actually more specific.

Rather specificity is a triplet of (ids sub-selectors, class sub-selectors, element sub-selectors). When attributes conflict, the one whose rule has the more specific selector wins.

The specificities of the rules you wrote out are (1,0,0), (0,1,0), (0,2,0), (0,1,0), (0,1,0), and (0,0,1).

In-line attributes (@style) beat out out-out-of line ones except if they’re !important. Specificity also disambiguates between !important attributes.



Thank you for the clarification, I hadn't realised that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: