Currently exploring the puzzling scenario where .x
seems to have higher specificity than *.x
, despite expectations.
Shouldn't *.x
technically have a specificity of 0-0-1-1
(1 class, 1 tag) while .x
is just one class with specificity 0-0-1-0
?
Let's take a look at this simple code snippet:
*.x { color: blue; }
.x { color: red }
<p class="x">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Atque, nam.</p>
The expected outcome should be blue. To illustrate an anticipated behavior, I swapped out *
for another element (p
):
p.x { color: blue; }
.x { color: red }
<p class="x">This time it works.</p>