I have html like:
header {
width: 100%;
height: 50px;
}
a {
color: red;
}
.my-a {
color: green;
}
<header class="my-header">
<div>
<a class="my-a" href="https://www.google.com">clickme</a>
</div>
</header>
Then 'clickme' will be green as expected. And it follows the rule that class selectors has a greater specificity than type selectors.
But when css becomes:
header {
width: 100%;
height: 50px;
}
.my-header a {
color: red;
}
.my-a {
color: green;
}
<header class="my-header">
<div>
<a class="my-a" href="https://www.google.com">clickme</a>
</div>
</header>
The result shows that 'clickme' is red which is out of my expectation. I cannot find any corresponding rule in MDN specificity.
Am i missing any rule here? JSFiddle