![]() |
CSS: Specificity
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) li0, 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! :) |
These numbers aren't helping. I recommend not using them lol...
Here's how the lineup would look like from weak to strong. Code:
#footer *:not(nav) liQuote:
*.error p.Code:
* {} |
I thought the id is stronger always! What do I know?
|
In-line css overwrite id's. Unless !important is used.
|
| All times are GMT +1. The time now is 08:21 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.