Which CSS selector has the highest specificity?
Options
div p.card .title#header(Correct option)p
Answer
#header
Why
When several CSS rules target the same element, the more specific selector wins. Ranking: inline styles > IDs > classes, attributes and pseudo-classes > element names.
#header (one ID) beats .card .title (two classes), which beats div p (two elements).
If specificity is equal, the rule written last wins. Avoid !important.
Remember
ID > class > element.