📌 If there are two or more conflicting CSS rules that point to the same element, the browser follows some rules to determine which one is most specific and therefore wins out.
🎯 Specificity Hierarchy
⇢ Every CSS selector has its place in the specificity hierarchy.
⇢ Four categories define the specificity level of a selector:
if the same rule is written twice into the external style sheet, then the lower rule in the style sheet is closer to the element to be styled
That's the reason for the red bg of div
⦿ ID selectors have a higher specificity than attribute selectors
⇢ Start at 0, add 100 for each ID value,add 10 for each class value (or pseudo-class or attribute selector),add 1 for each element selector or pseudo-element
→ The specificity of A is 1 (one element selector)
→ The specificity of B is 101 (one ID reference + one element selector)
→ The specificity of C is 1000 (inline styling)
Since the third rule (C) has the highest specificity value (1000),this style declaration will be applied
Open Peeps is a hand-drawn illustration library to create scenes of people. You can use them in product illustration, marketing, comics, and product states.