Skip to content

Instantly share code, notes, and snippets.

@chrislaughlin
Created February 14, 2024 10:09
Show Gist options
  • Save chrislaughlin/7bf0c00d778ffe3c125f213b1b5a77c9 to your computer and use it in GitHub Desktop.
Save chrislaughlin/7bf0c00d778ffe3c125f213b1b5a77c9 to your computer and use it in GitHub Desktop.
Specificity Showdown: Can You Guess the Winner?
The correct answer is A. Rule 1 (.container h2.special). Here's why:
Specificity is calculated based on the number of IDs, classes, and elements in the selector.
Rule 1 has one ID (.container), one class (.special), and one element (h2), giving it a value of 100 + 10 + 1 = 111.
Rule 2 only has one class and one element (10 + 1 = 11).
Rule 3 only has one ID and one class (100 + 10 = 110).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment