#hero { background-color: #dbeafe; }\n.banner { background-color: #e2e8f0; }The element with both ID and class keeps the #hero background.
LESSON 17 OF 100
Compare ID specificity with class specificity.
The ID component of specificity is compared before classes and types, so a matching ID beats a normal class selector.
#hero { background-color: #dbeafe; }\n.banner { background-color: #e2e8f0; }The element with both ID and class keeps the #hero background.
.banner { background-color: #dbeafe; }\n.banner { background-color: #e2e8f0; }With two identical class selectors, the second background wins by source order.
Complete the #hero rule with #dbeafe and keep the .banner rule after it.
The ID wins through its specificity component even though the class is declared later.
ANALYSIS REQUEST
The initial discussion is without obligation. You receive an honest recommendation, suitable stages and the factors that affect price.