What is specificity in CSS?
Specificity is the way the browser decides which rule wins when more than one rule applies to the same element. A stronger selector wins.
- Inline style is the strongest.
- Then
#idselectors. - Then
.class,[attribute]and:pseudo-class. - The weakest are element selectors like
p.
p { color: blue; }
.note { color: green; }
#intro { color: red; } /* wins for <p id="intro" class="note"> */
If the specificity is equal, the later rule wins. See CSS Specificity.
Learn more about the similar topics:
| Tutorials |
|---|
| CSS Selectors |
| CSS Specificity |
| CSS Pseudo-classes and Pseudo-elements |
| Exercises & Assignments |
|---|
| No Content Found. |