#id和div#id之间的区别 [英] Difference between #id and div#id
本文介绍了#id和div#id之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是CSS的新手.有人可以帮助我区分"#test"和"div#test"吗?
I am new to css. Can someone help me in differentiating "#test" and "div#test"?
<html>
<head></head>
<body>
<div>
<span>Some stuff here..</span>
</div>
<div id="test">
<span>This is my data</span>
</div>
</body>
</html>
推荐答案
You really ought not to qualify an ID with a tagname per the MDN, as follows:
不要用标签名称或类别来限定ID规则
Don’t qualify ID rules with tag names or classes
如果规则具有ID 选择器作为其关键选择器,请勿将标签名称添加到规则中. 由于ID是唯一的,因此添加标签名称会减慢匹配速度 不必要地处理
If a rule has an ID selector as its key selector, don’t add the tag name to the rule. Since IDs are unique, adding a tag name would slow down the matching process needlessly
这篇关于#id和div#id之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文