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