Algorithm defined here: https://drafts.csswg.org/selectors-3/#specificity
selector_specificity(sel)
sel | selector |
---|
numeric value
A selector's specificity is calculated as follows:
count the number of ID selectors in the selector (= a)
count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)
count the number of type selectors and pseudo-elements in the selector (= c)
ignore the universal selector
Selectors inside the negation pseudo-class are counted like any other, but the negation itself does not count as a pseudo-class.
Concatenating the three numbers a-b-c (in a number system with a large base) gives the specificity.
Since we only really have base-10 numbers (rather than numbers in arbitrarily large bases), just use 2 digits for each of the counts. Hopefully it is really unlikely that any of the counts exceeds 99!