按照我之前的想法,元素的特异性低于类,当然还有嵌套类。那么,为什么要这样做 <P>
标签优先?它在物理上更接近文本,没错,但我认为更具体的选择器是 .a .b
覆盖它。
<div class="a">
<div class="b">
<p>asdf</p> <!-- this text is 15pt red -->
</div>
</div>
p{
color: red;
}
.a .b{
color: blue;
font-size: 15pt;
}
最佳答案
更具体的选择器根本不匹配元素。
p { 颜色:红色; }
覆盖默认的 color: inherit
。
关于html - 为什么这个选择器优先于更具体的选择器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37596334/