麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 開發 > HTML5 > 正文

HTML5中div、article、section的區別及使用介紹

2024-09-05 07:20:29
字體:
來源:轉載
供稿:網友
最近正在學習html5,剛接觸html5,感覺有點不適應,因為有一些標簽改變了,特別是div, section article這三個標簽,查了一些資料,也試著用html5和css3布局網頁,稍微有點頭緒了,下邊還有一個我剛剛布局好的一個簡單的網頁,供大家參考,先看一下,最起碼心里對html5的結構有些概念。

div

HTML Spec: “The div element has no special meaning at all.”

這個標簽是我們見得最多、用得最多的一個標簽。本身沒有任何語義,用作布局以及樣式化或腳本的鉤子(hook)。

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 的無語義相對,簡單地說 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.”

當元素內容聚合起來更加言之有物時,應該使用 article 來替換 section 。

那么,section 應該什么時候用呢?再接著看:

“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.”

section 應用的典型場景有文章的章節、標簽對話框中的標簽頁、或者論文中有編號的部分。一個網站的主頁可以分成簡介、新聞和聯系信息等幾部分。其實我對這里傳達信息很感興趣,因為感覺 section 和下面要介紹的 artilce 更加適用于模塊化應用,這個話題以后會出篇專門的文章來討論,這里暫時略過。

要注意,W3C 還警告說:

“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 不僅僅是一個普通的容器標簽。當一個標簽只是為了樣式化或者方便腳本使用時,應該使用 div 。一般來說,當元素內容明確地出現在文檔大綱中時,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.”

article 是一個特殊的 section 標簽,它比 section 具有更明確的語義, 它代表一個獨立的、完整的相關內容塊。一般來說, article 會有標題部分(通常包含在 header 內),有時也會 包含 footer 。雖然 section 也是帶有主題性的一塊內容,但是無論從結構上還是內容上來說,article 本身就是獨立的、完整的。

HTML Spec 中接著又列舉了一些 article 適用的場景。 “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.”

當 article 內嵌 article 時,原則上來說,內部的 article 的內容是和外層的 article 內容是相關的。例如,一篇博客文章中,包含用戶提交的評論的 article 就應該潛逃在包含博客文章 article 之中。

問題是怎么才算“完整的獨立內容”?有個最簡單的判斷方法是看這段內容在 RSS feed 中是不是完整的。看這段內容脫離了所在的語境,是否還是完整的、獨立的。

例子:

html頁面:

復制代碼
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 欧美日比视频 | 在线播放中文 | 做爰xxxⅹ性护士hd在线 | 在线看91 | 密室逃脱第一季免费观看完整在线 | 精品国产看高清国产毛片 | av在线免费网 | 成人羞羞在线观看网站 | 国产精品18久久久久久久 | 19禁国产精品福利视频 | 精品一区在线视频 | 日本免费aaa观看 | 粉嫩粉嫩一区二区三区在线播放 | av电影免费播放 | 成人视屏在线 | 国产一区精品在线观看 | 久久久久久久高清 | 久久av免费观看 | 欧美日本在线视频 | 男女无套免费视频 | 一区二区三区欧美在线观看 | 久久国产精品二区 | 337p日本欧洲亚洲大胆精蜜臀 | www久久久久久 | 羞羞的视频免费观看 | xxxx69hd一hd| 羞羞视频免费网站含羞草 | 色成人在线 | 欧美精品18| 欧美a视频| 久久久久国产成人精品亚洲午夜 | 黄色试看视频 | 密室逃脱第一季免费观看完整在线 | 久久久三级免费电影 | 国产高清美女一级毛片久久 | 毛片在线视频免费观看 | 禁漫天堂久久久久久久久久 | 在线观看免费毛片视频 | 深夜影院一级毛片 | av电影在线观看网址 | 黄色网战入口 |