P粉7397060892023-08-23 20:07:38
In order, 1 is the lowest specificity and 5 is the highest. https://youtu.be/NqDb9GfMXuoDetails will be shown for demonstration.
P粉3842444732023-08-23 17:29:30
I'll just add a link here to the CSS 2.1 specification itself, and how browsers should calculate specificity:
If specificities are equal, CSS 2.1 Section 6.4.1 :
will be usedPlease note that this is discussed when the style is defined, not when used. If the specificities of classes .a
and .b
are equal, the class last defined in the stylesheet will win. <p class="a b">...</p>
and <p class="b a">...</p>
will Set in the same style according to the definition order of .a
and .b
.