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 的無語義相對,簡單地說 section 就是帶有語義的 div 了,但是千萬不要覺得真得這么簡單。section 表示一段專題性的內容,一般會帶有標題。看到這里,我們也許會想到,那么一篇博客文章,或者一條多帶帶的評論豈不是正好可以用 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.”
section 不僅僅是一個普通的容器標簽。當一個標簽只是為了樣式化或者方便腳本使用時,應該使用 div 。一般來說,當元素內容明確地出現在文檔大綱中時,section 就是適用的。
例子:
Apples
Tasty, delicious fruit!
The apple is the pomaceous fruit of the apple tree.
Red Delicious
These bright red apples are the most common found in many supermarkets.
Granny Smith
These juicy, green apples make a great filling for apple pies.
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.”