在CSS中,在div(例如)上设置样式时,除了为匹配提供更高的精度之外,还包括div。浏览器是否可以更快地呈现?
In CSS, when setting a style on a div (for example) is there any benefit in including the 'div' other than to give it more precision for matching. Is it faster for the browser to render perhaps?
即是:
div.something { font-size: 1em; }优于
.something { font-size: 1em; }因为任何其他原因,而不是缩小到只有divs?
for any other reason than to narrow it down to only divs?
(我要求的原因是我最近碰到了一个突出的网站,其中包含了'div,但最不倾向)
更新:
感谢所有的答案。结论是,速度是一个因素,但不明显这么值得忽略。对最佳实践的共识是,包含标签是更清洁的 - 一般规则应该保持CSS尽可能紧尽可能为所需的风格。
Thanks for all the answers. The conclusion is that speed is a factor but not noticeable so worth ignoring. And the consensus on the best practice is that including the tag is cleaner - general rule should be to keep the CSS as 'tight' as possible for the required style.
推荐答案除了两个选择器的不同语义外,请阅读: CSS的速度
Besides the different semantics of both selectors, read this: Speed of CSS
更多推荐
CSS中的更好:div.something或只是.something
发布评论