section HTML Spec: “The section element represents a generic section of a document or application. A section, in this context, is a thematic grouping of content, typically with a heading.”
與 div 的無(wú)語(yǔ)義相對(duì),簡(jiǎn)單地說(shuō) section 就是帶有語(yǔ)義的 div 了,但是千萬(wàn)不要覺得真得這么簡(jiǎn)單。section 表示一段專題性的內(nèi)容,一般會(huì)帶有標(biāo)題。看到這里,我們也許會(huì)想到,那么一篇博客文章,或者一條單獨(dú)的評(píng)論豈不是正好可以用 section 嗎?接著看:
“Authors are encouraged to use the article element instead of the section element when it would make sense to syndicate the contents of the elemen.”
“Examples of sections would be chapters, the various tabbed pages in a tabbed dialog box, or the numbered sections of a thesis. A Web site’s home page could be split into sections for an introduction, news items, and contact information.”
“The section element is not a generic container element. When an element is needed for styling purposes or as a convenience for scripting, authors are encouraged to use the div element instead. A general rule is that the section element is appropriate only if the element’s contents would be listed explicitly in the document’s outline.”
section 不僅僅是一個(gè)普通的容器標(biāo)簽。當(dāng)一個(gè)標(biāo)簽只是為了樣式化或者方便腳本使用時(shí),應(yīng)該使用 div 。一般來(lái)說(shuō),當(dāng)元素內(nèi)容明確地出現(xiàn)在文檔大綱中時(shí),section 就是適用的。
article HTML Spec: “The article element represents a self-contained composition in a document, page, application, or site and that is, in principle, independently distributable or reusable, e.g. in syndication.”
HTML Spec 中接著又列舉了一些 article 適用的場(chǎng)景。 “This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.”