html中div标签和section标签之间的区别及其用法 [英] Difference between div tag and section tag in html and their use

查看:316
本文介绍了html中div标签和section标签之间的区别及其用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

html中div标签和section标签之间的区别以及它们与示例一起使用哪个更好用,以及为什么

Difference between div tag and section tag in html and their use with examples and which is better to use and why

推荐答案

这是规范说的:

http://www.w3。 org / html / wg / drafts / html / master / semantics.html#the-section-element [ ^ ]



我的意见是它更多关于页面的语义方面。例如,当您有报纸网站或博客时,您已经严格定义了布局。而不是使用
Here is what spec says:
http://www.w3.org/html/wg/drafts/html/master/semantics.html#the-section-element[^]

My opinion is that it is more about semantic side of your page. When you for example have a newspaper website or blog, you have strictly defined layout. And instead of using

,您将使用article标签。但是没有人强迫你去做。你的页面与div和文章的工作方式完全相同。



所以我说这更多是关于语义的,也许将来搜索引擎会给你一些加点使用这个,也许不是:)。



这里也是关于这个话题的非常好的文章:



http://html5doctor.com/the-section-element/ [ ^ ]



如果你不想读它所有最好的部分是我认为:





使用部分的经验法则



当然,总有例外,但这些应该为99%的案例提供有用的指导:



Don'使用它作为造型或脚本的钩子;这是一个div

不要使用它,如果文章,旁边或导航更合适

不要使用它,除非在该部分的开头自然有一个标题

修订后的规范(截至9月16日)说:

鼓励作者使用article元素而不是section元素,因为联合内容是有意义的元素。

由于博客文章和评论通常是联合的(通过被拉入其他博客或通过twitter,reddit等链接),它们应该是文章。

you will use article tag. But nobody forces you to do it. You page will work exactly the same with div and with article.

So as I said it is more about semantic and maybe in a future the search engines will give you some plus points for using this and maybe not :).

here is a very good article about this topic too:

http://html5doctor.com/the-section-element/[^]

if you dont want to read it all best part is I think this:


Rules of thumb for using section

Of course, there are always exceptions, but these should give useful guidance for 99% of cases:

Don't use it just as hook for styling or scripting; that's a div
Don't use it if article, aside or nav is more appropriate
Don't use it unless there is naturally a heading at the start of the section
The revised spec (as of 16 September) says:
Authors are encouraged to use the article element instead of the section element when it would make sense to syndicate the contents of the element.
As blogposts and comments are often syndicated (by being pulled into other blogs or being linked via twitter, reddit etc) they should be articles.

这篇关于html中div标签和section标签之间的区别及其用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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