简体   繁体   English

HTML效率,最佳做法

[英]HTML efficiency, best practices

In the past, I created some divs to act like articles. 过去,我创建了一些div来充当文章。 Now I am thinking about changing it to HTML5 tag article ... 现在,我正在考虑将其更改为HTML5标签文章 ...

Is there an important diference (in terms of efficiency) between using HTML elements or using equivalent divs created by the user? 使用HTML元素或使用用户创建的等效div之间(在效率方面)有重要区别吗? For example: Will the browser load the pages faster if they are built only with HTML elements? 例如:如果仅使用HTML元素构建页面,浏览器会更快地加载页面吗?

Short answer: No. 简短答案:不可以。

Long answer: maybe, if it will decrease the amount of markup you use. 长答案:也许,如果这样做会减少您使用的标记量。 But not likely. 但是不太可能。

The benefit of using semantic tags is to add more meaning to the markup, not improve performance. 使用语义标签的好处是为标记增加了更多含义,而不是提高性能。

May be. 也许。 When you cretae a div and add styling to it, the browser needs to first interpret the element and then process the style over it and render it. 当创建一个div并添加样式时,浏览器需要首先解释该元素,然后处理该元素上的样式并进行渲染。 If you use the appropriate HTML element, it would put less burden on the rendering engine. 如果使用适当的HTML元素,它将减轻渲染引擎的负担。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM