.myclass), attribute selectors (ex.: [href=^https:]) and pseudo-classes (ex.: :hover)div) and pseudo-elements (ex.: ::before)To compare the specificity of two combined selectors, compare the number of occurences of single selectors of each of the specificity groups above.
Example: compare #nav ul li a:hover to #nav ul li.active a::after
- count the number of id selectors: there is one for each (
#nav) - count the number of class selectors: there is one for each (
:hoverand.active) - count the number of element selectors: there are 3 (
ul li a) for the first and 4 for the second (ul li a ::after), thus the second combined selector is more specific.
A good article about css selector specificity.
加载中...