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 1067328 of <section>

  • Revision slug: Web/HTML/Element/section
  • Revision title: <section>
  • Revision id: 1067328
  • Created:
  • Creator: Popodopolos
  • Is current revision? No
  • Comment Maintaining the Before and After pattern presents the material more clearly. Having to types of presentations for the same issue deviates from artistic convention.The same style of presenting the material is consistent and less confusing.

Revision Content

{{HTMLRef}}

The HTML <section> element represents a generic section of a document, i.e., a thematic grouping of content, typically with a heading. Each <section> should be identified, typically by including a heading ({{HTMLElement('h1')}}-{{HTMLElement('h6')}} element) as a child of the <section> element.

Usage notes :

  • If it makes sense to separately syndicate the content of a {{HTMLElement("section")}} element, use an {{HTMLElement("article")}} element instead.
  • Do not use the {{HTMLElement("section")}} element as a generic container; this is what {{HTMLElement("div")}} is for, especially when the sectioning is only for styling purposes. A rule of thumb is that a section should logically appear in the outline of a document.
Content categories Flow content, Sectioning content, palpable content.
Permitted content Flow content.
Tag omission {{no_tag_omission}}
Permitted parent elements Any element that accepts flow content. Note that a {{HTMLElement("section")}} element must not be a descendant of an {{HTMLElement("address")}} element.
DOM interface {{domxref("HTMLElement")}}

Attributes

This element only includes the global attributes.

Example 1

Before

<div>
  <h1>Heading</h1>
  <p>Bunch of awesome content</p>
</div>

After

<section>
  <h1>Heading</h1>
  <p>Bunch of awesome content</p>
</section>

Example 2

Before

<div>
  <h2>Heading</h2>
  <img src="bird.jpg" alt="bird">
</div>

After

<section>
  <h2>Heading</h2>
  <img src="bird.jpg" alt="bird">
</section>

Specifications

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

Browser compatibility

{{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)

See also

  • Other section-related elements: {{HTMLElement("body")}}, {{HTMLElement("nav")}}, {{HTMLElement("article")}}, {{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.

Revision Source

<p>{{HTMLRef}}</p>

<p>The <strong>HTML <code>&lt;section&gt;</code> element</strong> represents a generic section of a document, i.e., a thematic grouping of content, typically with a heading. Each <code>&lt;section&gt;</code> should be identified, typically by including a heading ({{HTMLElement('h1')}}-{{HTMLElement('h6')}} element) as a child of the <code>&lt;section&gt;</code> element.</p>

<div class="note">
<p><em>Usage notes :</em></p>

<ul>
 <li>If it makes sense to separately syndicate the content of a {{HTMLElement("section")}} element, use an {{HTMLElement("article")}} element instead.</li>
 <li>Do not use the {{HTMLElement("section")}} element as a generic container; this is what {{HTMLElement("div")}} is for, especially when the sectioning is only for styling purposes. A rule of thumb is that a section should logically appear in the outline of a document.</li>
</ul>
</div>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row"><a href="/en-US/docs/Web/HTML/Content_categories">Content categories</a></th>
   <td><a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">Flow content</a>, <a href="/en-US/docs/Web/HTML/Content_categories#Sectioning_content">Sectioning content</a>, palpable content.</td>
  </tr>
  <tr>
   <th scope="row">Permitted content</th>
   <td><a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">Flow content</a>.</td>
  </tr>
  <tr>
   <th scope="row">Tag omission</th>
   <td>{{no_tag_omission}}</td>
  </tr>
  <tr>
   <th scope="row">Permitted parent elements</th>
   <td>Any element that accepts <a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">flow content</a>. Note that a {{HTMLElement("section")}} element must not be a descendant of an {{HTMLElement("address")}} element.</td>
  </tr>
  <tr>
   <th scope="row">DOM interface</th>
   <td>{{domxref("HTMLElement")}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Attributes">Attributes</h2>

<p>This element only includes the <a href="/en-US/docs/Web/HTML/Global_attributes">global attributes</a>.</p>

<h2 id="Examples">Example 1</h2>

<h3>Before</h3>

<pre>
&lt;div&gt;
  &lt;h1&gt;Heading&lt;/h1&gt;
  &lt;p&gt;Bunch of awesome content&lt;/p&gt;
&lt;/div&gt;</pre>

<h3>After</h3>

<pre class="brush: html">
&lt;section&gt;
  &lt;h1&gt;Heading&lt;/h1&gt;
  &lt;p&gt;Bunch of awesome content&lt;/p&gt;
&lt;/section&gt;
</pre>

<h2 id="Example_2">Example 2</h2>

<h3 id="Before">Before</h3>

<pre class="brush: html">
&lt;div&gt;
  &lt;h2&gt;Heading&lt;/h2&gt;
  &lt;img src="bird.jpg" alt="bird"&gt;
&lt;/div&gt;
</pre>

<h3 id="After">After</h3>

<pre class="brush: html">
&lt;section&gt;
  &lt;h2&gt;Heading&lt;/h2&gt;
  &lt;img src="bird.jpg" alt="bird"&gt;
&lt;/section&gt;
</pre>

<h2 id="Specifications">Specifications</h2>

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

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>{{CompatibilityTable}}</div>

<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="See_also">See also</h2>

<ul>
 <li>Other section-related elements: {{HTMLElement("body")}}, {{HTMLElement("nav")}}, {{HTMLElement("article")}}, {{HTMLElement("aside")}}, {{HTMLElement("h1")}}, {{HTMLElement("h2")}}, {{HTMLElement("h3")}}, {{HTMLElement("h4")}}, {{HTMLElement("h5")}}, {{HTMLElement("h6")}}, {{HTMLElement("hgroup")}}, {{HTMLElement("header")}}, {{HTMLElement("footer")}}, {{HTMLElement("address")}};</li>
 <li><a href="/en-US/docs/Sections_and_Outlines_of_an_HTML5_document">Sections and outlines of an HTML5 document</a>.</li>
</ul>
Revert to this revision