div:自己没有任何语义,用做布局以及样式化。app
section:与 div 的无语义相对,简单地说 section 就是带有语义的 div 了,可是千万不要以为真得这么简单。section 表示一段专题性的内容,通常会带有标题。section 应用的典型场景有文章的章节、标签对话框中的标签页、或者论文中有编号的部分。一个网站的主页能够分红简介、新闻和联系信息等几部分。section 不单单是一个普通的容器标签。当一个标签只是为了样式化或者方便脚本使用时,应该使用 div 。通常来讲,当元素内容明确地出如今文档大纲中时,section 就是适用的。ide
<article> <hgroup> <h1>Apples</h1> <h2>Tasty, delicious fruit!</h2> </hgroup> <p>The apple is the pomaceous fruit of the apple tree.</p> <section> <h1>Red Delicious</h1> <p>These bright red apples are the most common found in many supermarkets.</p> </section> <section> <h1>Granny Smith</h1> <p>These juicy, green apples make a great filling for apple pies.</p> </section> </article>
article:这是一个特殊的 section 标签,它比 section 具备更明确的语义, 它表明一个独立的、完整的相关内容块。通常来讲,
article 会有标题部分(一般包含在 header 内),有时也会 包含 footer 。虽然 section
也是带有主题性的一块内容,可是不管从结构上仍是内容上来讲,article 自己就是独立的、完整的。当 article 内嵌 article 时,原则上来讲,内部的 article 的内容是和外层的 article 内容是相关的。例如,一篇博客文章中,包含用户提交的评论的 article 就应该潜逃在包含博客文章 article 之中。布局
<article> <header> <h1>The Very First Rule of Life</h1> <p><time pubdate datetime="2009-10-09T14:28-08:00"></time></p> </header> <p>If there's a microphone anywhere near you, assume it's hot and sending whatever you're saying to the world. Seriously.</p> <p>...</p> <section> <h1>Comments</h1> <article> <footer> <p>Posted by: George Washington</p> <p><time pubdate datetime="2009-10-10T19:10-08:00"></time></p> </footer> <p>Yeah! Especially when talking about your lobbyist friends!</p> </article> <article> <footer> <p>Posted by: George Hammond</p> <p><time pubdate datetime="2009-10-10T19:15-08:00"></time></p> </footer> <p>Hey, you have the same first name as me.</p> </article> </section> </article>
总结:div section article ,语义是从无到有,逐渐加强的。div
无任何语义,仅仅用做样式化,对于一段主题性的内容,则就适用
section,而假如这段内容能够脱离上下文,做为完整的独立存在的一段内容,则就适用 article。原则上来讲,能使用 article
的时候,也是可使用 section 的,可是实际上,假如使用 article 更合适,那么就不要使用 section 。nav 和 aside
的使用也是如此,这两个标签也是特殊的 section,在使用 nav 和 aside 更合适的状况下,也不要使用 section 了。网站
对于 div 和 section、 article 以及其余标签的区分比较简单。对于 section 和 article
的区分乍看比较难,其实重点就是看看这段内容脱离了总体是否是还能做为一个完整的、独立的内容而存在,这里面的重点又在完整身上。由于其实提及来
section 包含的内容也能算做独立的一块,可是它只能算是组成总体的一部分,article 才是一个完整的总体。ui
文章转载百度知道,感谢提问人以及回答者 明M_M_M_M spa