CSS is crap!

…not that I want to go back to straight HTML, because that's crap, but CSS is crap too.

After pulling my hair out for a bit and wondering why my styles weren't applying I found this helpful article on CSS specificity. Here's the good part:

Element, Pseudo Element: d = 1 – (0,0,0,1)
Class, Pseudo class, Attribute: c = 1 – (0,0,1,0)
Id: b = 1 – (0,1,0,0)
Inline Style: a = 1 – (1,0,0,0)

(1,0,0,0) is the most specific, (0,0,0,1) is the least. When conflicts exist, the most specific wins. So, (0,0,1,0) always wins out over (0,0,0,15). Also if two are in conflict and have the same specificity, then the one declared last wins.

Good to note. Back to work!

Leave a Reply

Your email address will not be published.