DEV Community

loading...

Discussion on: Why you should forget about !important?

Collapse
afif profile image
Temani Afif

The specificity calculation doesn't really use points the way you described. Considering your logic, if we have 11 classes we will get 11*10=110 points and this will be bigger than the 100 points of the ID but still the ID will win.

This is a well known confusion in many articles (and a well known SO question around the subject: stackoverflow.com/q/2809024/8620333)

Refer to the official specification for accurate detail about the calculation: w3.org/TR/selectors-4/#specificity... you will see that we calculate 3 components and we do a comparaison one by one.

Collapse
hugolyra profile image
Hugo Lyra Author • Edited

Thanks, update with what I learn from you ;)