<分区>
标签 html css css-selectors
<分区>
从这里question ,据我所知,css 选择器不区分大小写,但 HTML 属性(类名)区分大小写,因此恕我直言,.example
应该被 .Example
覆盖css 选择器,但这不会发生。 <div class="example">
颜色仍然是红色而不是我认为的蓝色,因为 css 选择器不区分大小写。
.example {
color: red;
}
.Example {
color: blue;
}
<div class="example">
example
</div>
最佳答案
你完全正确! CSS 实际上主要是不区分大小写的。
但是 HTML 4.01 定义类名和 ID 名区分大小写,这在 HTML5 中没有改变。
All CSS syntax is case-insensitive within the ASCII range (i.e., [a-z] and [A-Z] are equivalent), except for parts that are not under the control of CSS. For example, the case-sensitivity of values of the HTML attributes "id" and "class", of font names, and of URIs lies outside the scope of this specification.
关于html - 如果 CSS 选择器不区分大小写,那么为什么不覆盖样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53885595/