HTML & CSS · Junior · Question 16 of 75

Both selectors set color on the same link. Which wins: #nav a or .menu .item a.link?

Explanation

Specificity is compared column by column (IDs, classes/attributes/pseudo-classes, types): #nav a = (1,0,1), .menu .item a.link = (0,3,1). The first column matters most, so the ID wins. Source order only decides when specificity is equal.

Further reading

Problem with a question

HTML & CSS · Junior · question 16

Test yourself

Take the HTML & CSS · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz