Why in the following code world
is blue rather than red?
The specificity of .my_class
is 0,0,1,0
, but it inherits the color of #my_id
which specificity is higher (0,1,0,0
).
#my_id {
color: red;
}
.my_class {
color: blue;
}
<p id='my_id'>
Hello
<span class='my_class'>
world
</span>
</p>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…