CSS Specificity
- •
What it is
- •
a selector weight used when competing declarations reach the same relevant cascade precedence
- •
- •
- •
Example
- •
[type="password"] { /* 0-1-0 */ } input:focus { /* 0-1-1 */ } :root #myApp input:required { /* 1-2-1 */ } #myElement { color: green; /* 1-0-0 - WINS!! */ } .bodyClass .sectionClass .parentClass [id="myElement"] { color: yellow; /* 0-4-0 */ }
- •
- •
Reference
- •
https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Cascade/Specificity
- •