DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> HTML基礎知識 >> HTML和Xhtml
HTML5 article 標籤:定義、範例與嵌套規則
編輯:HTML和Xhtml     

定義與用法

<article> 標籤用來定義一段可獨立分發的內容。典型的例子包括:來自外部新聞來源的一篇報導、部落格中的一篇文章、論壇上的一篇討論,或任何來自其他來源、可以脫離當前頁面獨立成立的內容。

判斷是否該用 <article> 的關鍵,不是它「看起來像不像一篇文章」,而是「把它整段搬到別的頁面或透過 RSS 訂閱輸出,讀者是否仍能理解」。若答案是肯定的,就適合使用。

HTML 4.01 與 HTML 5 的差異

<article> 是 HTML5 新增的標籤,在 HTML 4.01 中並不存在。

範例

<article>
  <h2>Netscape Is Dead</h2>
  <p>AOL has now officially announced that they will end the development
  and support of all Netscape browsers.</p>
</article>

提示與備註

備註:<article> 標籤的內容獨立於文件的其餘部分。

這也是 <article> 可以嵌套的原因。以一篇帶有留言的文章為例,文章本文是一個 <article>,而每一則留言同樣具備獨立性(有作者、時間、內容),因此也應該各自包在 <article> 裡,整體再放進最外層的文章 <article> 中:

<article>
  <h1>文章標題</h1>
  <p>文章本文...</p>

  <article>
    <h2>留言標題</h2>
    <p>留言內容...</p>
  </article>
</article>

屬性

標準屬性

class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark, tabindex, template, title

事件屬性

onabort, onbeforeunload, onblur, onchange, onclick, oncontextmenu, ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress, onkeyup, onload, onmessage, onmousedown, onmousemove, onmouseover, onmouseout, onmouseup, onmousewheel, onresize, onscroll, onselect, onsubmit, onunload

相對於 <section>,<article> 更強調「可獨立聚合」,而 <section> 偏向「描述文件結構」。兩者都可能帶有自己的 <header> 與 <footer>,而 <article> 內部通常會以標題元素起頭,讓文件大綱能正確辨識這個區塊的層級。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved