CSS选择器是否区分大小写? [英] Are CSS selectors case-sensitive?

查看:792
本文介绍了CSS选择器是否区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近更新了一个CMS网站,并在标签页导航插件中插入了以下标记:

I was recently updating a CMS site and a tab-navigation plugin had inserted the following markup:

<li id="News_tab">...

我一直用小写写CSS选择器,我尝试用 #news_tab 来设置样式,但不适用,但 #News_tab 工作。

I've always written my CSS selectors in lowercase so when I tried to style this with #news_tab, it wouldn't apply, but #News_tab worked.

经过这些年,我很惊讶,我以前没有遇到过这种情况,所以我一直受到CSS的不区分大小写的印象。 CSS总是区分大小写,我只是没有注意到我感谢我一致的代码风格?

After all these years I'm surprised that I haven't run into this before, so I've always been under the impression that CSS was case-insensitive. Has CSS always been case-sensitive and I just haven't noticed thanks to my consistent code style?

推荐答案

CSS本身是case不区分大小写,但来自HTML(类和ID)的选择器区分大小写:

CSS itself is case insensitive, but selectors from HTML (class and id) are case sensitive:

CSS建议区分大小写

HTML推荐,ID属性(注意[CS])

这篇关于CSS选择器是否区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆