gpt4 book ai didi

html - #id 和 div#id 之间的区别

转载 作者:太空宇宙 更新时间:2023-11-03 19:39:30 25 4
gpt4 key购买 nike

我是 CSS 新手。谁能帮我区分“#test”和“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>

最佳答案

根据 MDN,您确实不应该使用标记名限定 ID ,如下:

Don’t qualify ID rules with tag names or classes

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

关于html - #id 和 div#id 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44583857/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com