Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 781935 of <article>

  • 版本网址缩略名: Web/HTML/Element/article
  • 版本标题: <article>
  • 版本 id: 781935
  • 创建于:
  • 创建者: RenGuangHui
  • 是否是当前版本?
  • 评论 示例代码修改

修订内容

<article>元素表示文档、页面、应用或网站中的独立结构,其意在成为可独立分配的或可复用的结构,如在发布中,它可能是论坛帖子、杂志或新闻文章、博客、用户提交的评论、交互式组件,或者其他独立的内容项目。

使用说明:

  • <article>元素嵌套使用时,则该元素代表与外层元素有关的文章。例如,代表博客评论的<article>元素可嵌套在代表博客文章的<article>元素中。
  • <article>元素的作者信息可通过{{HTMLElement("address")}}元素提供,但是不适用于嵌套的<article>元素。
  • <article>元素的发布日期和时间可通过{{HTMLElement("time")}}元素的{{htmlattrxref("pubdate", "time")}}属性表示。

  • 内容分类 Flow content, sectioning content, palpable content.
  • 许可内容Flow content.
  • 标记省略 {{no_tag_omission}}
  • 父元素所有接受 flow content的元素。注意<article>元素不能成为{{HTMLElement("address")}}元素的子元素。
  • DOM interface {{domxref("HTMLElement")}}

属性

只具有全局属性

示例

<article class="film_review">
  <header>
    <h2>Jurassic Park</h2>
  </header>
  <section class="main_review">
    <p>Dinos were great!</p>
  </section>
  <section class="user_reviews">
    <article class="user_review">
      <p>Way too scary for me.</p>
      <footer>
        <p>
          Posted on <time datetime="2015-05-16 19:00">May 16</time> by Lisa.
        </p>
      </footer>
    </article>
    <article class="user_review">
      <p>I agree, dinos are my favorite.</p>
      <footer>
        <p>
          Posted on <time datetime="2015-05-17 19:00">May 17</time> by Tom.
        </p>
      </footer>
    </article>
  </section>
  <footer>
    <p>
      Posted on <time datetime="2015-05-15 19:00">May 15</time> by Staff.
    </p>
  </footer>
</article>

标准

Specification Status Comment
{{SpecName('HTML WHATWG', 'sections.html#the-article-element', '<article>')}} {{Spec2('HTML WHATWG')}}  
{{SpecName('HTML5 W3C', 'sections.html#the-article-element', '<article>')}} {{Spec2('HTML5 W3C')}}  

浏览器兼容

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 5 {{CompatGeckoDesktop("2.0")}} 9.0 11.10 4.1
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 2.2 {{CompatGeckoMobile("2.0")}} 9.0 11.0 5.0 (iOS 4.2)

相关文章

  • Others section-related elements: {{HTMLElement("body")}}, {{HTMLElement("nav")}}, {{HTMLElement("section")}}, {{HTMLElement("aside")}}, {{HTMLElement("h1")}}, {{HTMLElement("h2")}}, {{HTMLElement("h3")}}, {{HTMLElement("h4")}}, {{HTMLElement("h5")}}, {{HTMLElement("h6")}}, {{HTMLElement("hgroup")}}, {{HTMLElement("header")}}, {{HTMLElement("footer")}}, {{HTMLElement("address")}}
  • Sections and outlines of an HTML5 document.

{{ HTMLRef }}

修订版来源

<p><code style="font-size: 14px;">&lt;article&gt;</code><span style="line-height: 1.5;">元素表示文档、页面、应用或网站中的独立结构,其意在成为可独立分配的或可复用的结构,如在发布中,它可能是论坛帖子、杂志或新闻文章、博客、用户提交的评论、交互式组件,或者其他独立的内容项目。</span></p>

<div class="note">
<p><strong>使用说明:</strong></p>

<ul>
 <li>当<code>&lt;article&gt;</code>元素嵌套使用时,则该元素代表与外层元素有关的文章。例如,代表博客评论的<code>&lt;article&gt;</code>元素可嵌套在代表博客文章的<code>&lt;article&gt;</code>元素中。</li>
 <li><code>&lt;article&gt;</code>元素的作者信息可通过{{HTMLElement("address")}}元素提供,但是不适用于嵌套的<code>&lt;article&gt;</code>元素。</li>
 <li>
  <p style="margin-bottom: 0px;"><code>&lt;article&gt;</code>元素的发布日期和时间可通过{{HTMLElement("time")}}元素的{{htmlattrxref("pubdate", "time")}}属性表示。</p>
 </li>
</ul>
</div>

<ul class="htmlelt">
 <li><dfn><a href="/en-US/docs/HTML/Content_categories" title="HTML/Content_categories">内容分类</a></dfn> <a href="/en-US/docs/HTML/Content_categories#Flow_content" title="HTML/Content categories#Flow content">Flow content</a>, sectioning content, palpable content.</li>
 <li><dfn>许可内容</dfn><a href="/en-US/docs/HTML/Content_categories#Flow_content" title="HTML/Content_categories#Flow_content">Flow content</a>.</li>
 <li><dfn>标记省略</dfn> {{no_tag_omission}}</li>
 <li><dfn>父元素</dfn>所有接受&nbsp;<a href="/en-US/docs/HTML/Content_categories#Flow_content" title="https://developer.mozilla.org/en/HTML/Content_categories#Flow_content">flow content</a>的元素。注意&lt;article&gt;元素不能成为{{HTMLElement("address")}}元素的子元素。</li>
 <li><dfn>DOM interface</dfn> {{domxref("HTMLElement")}}</li>
</ul>

<h2 id=".E5.B1.9E.E6.80.A7">属性</h2>

<p><span style="line-height: 21px;">只具有<a href="https://developer.mozilla.org/en-US/docs/HTML/Global_attributes">全局属性</a>。</span></p>

<h2 id=".E7.A4.BA.E4.BE.8B">示例</h2>

<pre class="brush: html  language-html" data-number="" style="padding: 1em 0px 1em 30px; font-size: 14px; white-space: normal; word-spacing: 0px; background-repeat: initial;">
<code class="language-html" style="direction: ltr; white-space: pre; word-spacing: normal; word-break: normal; tab-size: 4;"><span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>article</span> <span class="token attr-name" style="color: rgb(102, 153, 0);">class</span><span class="token attr-value" style="color: rgb(0, 119, 170);"><span class="token punctuation" style="color: rgb(153, 153, 153);">=</span><span class="token punctuation" style="color: rgb(153, 153, 153);">"</span>film_review<span class="token punctuation" style="color: rgb(153, 153, 153);">"</span></span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
  <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>header</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
    <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>h2</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>Jurassic Park<span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>h2</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
  <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>header</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
  <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>section</span> <span class="token attr-name" style="color: rgb(102, 153, 0);">class</span><span class="token attr-value" style="color: rgb(0, 119, 170);"><span class="token punctuation" style="color: rgb(153, 153, 153);">=</span><span class="token punctuation" style="color: rgb(153, 153, 153);">"</span>main_review<span class="token punctuation" style="color: rgb(153, 153, 153);">"</span></span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
    <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>p</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>Dinos were great!<span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>p</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
  <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>section</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
  <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>section</span> <span class="token attr-name" style="color: rgb(102, 153, 0);">class</span><span class="token attr-value" style="color: rgb(0, 119, 170);"><span class="token punctuation" style="color: rgb(153, 153, 153);">=</span><span class="token punctuation" style="color: rgb(153, 153, 153);">"</span>user_reviews<span class="token punctuation" style="color: rgb(153, 153, 153);">"</span></span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
    <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>article</span> <span class="token attr-name" style="color: rgb(102, 153, 0);">class</span><span class="token attr-value" style="color: rgb(0, 119, 170);"><span class="token punctuation" style="color: rgb(153, 153, 153);">=</span><span class="token punctuation" style="color: rgb(153, 153, 153);">"</span>user_review<span class="token punctuation" style="color: rgb(153, 153, 153);">"</span></span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
      <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>p</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>Way too scary for me.<span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>p</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
      <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>footer</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
        <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>p</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
          Posted on <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>time</span> <span class="token attr-name" style="color: rgb(102, 153, 0);">datetime</span><span class="token attr-value" style="color: rgb(0, 119, 170);"><span class="token punctuation" style="color: rgb(153, 153, 153);">=</span><span class="token punctuation" style="color: rgb(153, 153, 153);">"</span>2015-05-16 19:00<span class="token punctuation" style="color: rgb(153, 153, 153);">"</span></span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>May 16<span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>time</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span> by Lisa.
        <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>p</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
      <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>footer</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
    <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>article</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
    <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>article</span> <span class="token attr-name" style="color: rgb(102, 153, 0);">class</span><span class="token attr-value" style="color: rgb(0, 119, 170);"><span class="token punctuation" style="color: rgb(153, 153, 153);">=</span><span class="token punctuation" style="color: rgb(153, 153, 153);">"</span>user_review<span class="token punctuation" style="color: rgb(153, 153, 153);">"</span></span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
      <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>p</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>I agree, dinos are my favorite.<span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>p</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
      <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>footer</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
        <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>p</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
          Posted on <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>time</span> <span class="token attr-name" style="color: rgb(102, 153, 0);">datetime</span><span class="token attr-value" style="color: rgb(0, 119, 170);"><span class="token punctuation" style="color: rgb(153, 153, 153);">=</span><span class="token punctuation" style="color: rgb(153, 153, 153);">"</span>2015-05-17 19:00<span class="token punctuation" style="color: rgb(153, 153, 153);">"</span></span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>May 17<span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>time</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span> by Tom.
        <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>p</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
      <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>footer</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
    <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>article</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
  <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>section</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
  <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>footer</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
    <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>p</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
      Posted on <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;</span>time</span> <span class="token attr-name" style="color: rgb(102, 153, 0);">datetime</span><span class="token attr-value" style="color: rgb(0, 119, 170);"><span class="token punctuation" style="color: rgb(153, 153, 153);">=</span><span class="token punctuation" style="color: rgb(153, 153, 153);">"</span>2015-05-15 19:00<span class="token punctuation" style="color: rgb(153, 153, 153);">"</span></span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>May 15<span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>time</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span> by Staff.
    <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>p</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
  <span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>footer</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span>
<span class="token tag" style="color: rgb(153, 0, 85);"><span class="token tag"><span class="token punctuation" style="color: rgb(153, 153, 153);">&lt;/</span>article</span><span class="token punctuation" style="color: rgb(153, 153, 153);">&gt;</span></span></code></pre>

<h2 id="Specifications" name="Specifications">标准</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'sections.html#the-article-element', '&lt;article&gt;')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'sections.html#the-article-element', '&lt;article&gt;')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>

<h2 id=".E6.B5.8F.E8.A7.88.E5.99.A8.E5.85.BC.E5.AE.B9">浏览器兼容</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>5</td>
   <td>{{CompatGeckoDesktop("2.0")}}</td>
   <td>9.0</td>
   <td>11.10</td>
   <td>4.1</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>2.2</td>
   <td>{{CompatGeckoMobile("2.0")}}</td>
   <td>9.0</td>
   <td>11.0</td>
   <td>5.0 (iOS 4.2)</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id=".E7.9B.B8.E5.85.B3.E6.96.87.E7.AB.A0">相关文章</h2>

<ul>
 <li>Others section-related elements: {{HTMLElement("body")}}, {{HTMLElement("nav")}}, {{HTMLElement("section")}}, {{HTMLElement("aside")}}, {{HTMLElement("h1")}}, {{HTMLElement("h2")}}, {{HTMLElement("h3")}}, {{HTMLElement("h4")}}, {{HTMLElement("h5")}}, {{HTMLElement("h6")}}, {{HTMLElement("hgroup")}}, {{HTMLElement("header")}}, {{HTMLElement("footer")}}, {{HTMLElement("address")}}</li>
 <li class="last"><a class="deki-ns current" href="/en-US/docs/Sections_and_Outlines_of_an_HTML5_document" title="Sections and Outlines of an HTML5 document">Sections and outlines of an HTML5 document</a>.</li>
</ul>

<p>{{ HTMLRef }}</p>
恢复到这个版本