Can someone please explain the concept of specificity to me, or point me to an article that explains it thoroughly. I understand the basics of specificity:
A class beats an element selector.
An ID selector beats a class and element selector.
The style attribute beats the ID, class and element selectors.
I also know that a Universal Selector has a specificity of 0, 0, 0, 0, which I've read is
not the same as having no specificity.
I've been using this website as reference to try and learn more about the specificity concepts of CSS:
http://css-tricks.com/specifics-on-css-specificity/
I'm particularly referring to the following example:
Code:
#footer *:not(nav) li
There are 0 style selectors, one ID selector, a universal selector, a psuedo-class selector, and two element selectors, however the outcome is:
0, 1, 0, 2
Is this because the universal selector has a specificity of 0, 0, 0, 0, and therefore, this is applied to whatever it is attached to?
So basically when people use universal selectors as a reset (bad, but using it as an example), it would be: 0, 0, 0, 0
If someone is using a universal selector on an element, (*ul li {font-style: italic;}) it would be: 0, 0, 0, 0
If someone is using a universal selector on a class, (*.error p {color: red;}) it would be: 0, 0, 0, 1
And so on an so forth, correct?
Thank you for any information that would help me further understand how this works!