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 934101 of <caption>

  • Revision slug: Web/HTML/Element/caption
  • Revision title: <caption>
  • Revision id: 934101
  • Created:
  • Creator: Sebastianz
  • Is current revision? No
  • Comment Replaced list for properties by table (bug 1212755) and removed translated tags

Revision Content

Summary

The HTML <caption> Element (or HTML Table Caption Element) represents the title of a table. Though it is always the first descendant of a {{HTMLElement("table")}}, its styling, using CSS, may place it elsewhere, relative to the table.

Usage note: When the {{HTMLElement("table")}} element that is the parent of this {{HTMLElement("caption")}} is the only descendant of a {{HTMLElement("figure")}} element, use the {{HTMLElement("figcaption")}} element instead.
Content categories None.
Permitted content Flow content.
Tag omission {{no_tag_omission}}
Permitted parent elements A {{HTMLElement("table")}} element, as its first descendant.
DOM interface {{domxref("HTMLTableCaptionElement")}}

Attributes

This element includes the global attributes.

{{htmlattrdef("align")}} {{deprecatedGeneric('inline','HTML4.01')}} {{obsoleteGeneric('inline','HTML5')}}
This enumerated attribute indicates how the caption must be aligned with respect to the table. It may have the following values:
  • left, displayed to the left of the table
  • top, displayed before the the table
  • right, displayed to the right of the table
  • bottom, displayed under the table
Usage note: Do not use this attribute, as it has been deprecated: the {{HTMLElement("caption")}} element should be styled using CSS. To give a similar effect to the align attribute, use the the CSS properties {{cssxref("caption-side")}} and {{cssxref("text-align")}}.

Examples

Please see the {{HTMLElement("table")}} page for examples on {{HTMLElement("caption")}}

Specifications

Specification Status Comment
{{SpecName('HTML WHATWG', 'tabular-data.html#the-caption-element', '<caption>')}} {{Spec2('HTML WHATWG')}}  
{{SpecName('HTML5 W3C', 'tabular-data.html#the-caption-element', '<caption>')}} {{Spec2('HTML5 W3C')}}  
{{SpecName('HTML4.01', 'struct/tables.html#h-11.2.2', '<caption>')}} {{Spec2('HTML4.01')}}  

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatVersionUnknown}} {{CompatGeckoDesktop("1.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatGeckoMobile("1.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}

See also

  • Other table-related HTML Elements: {{HTMLElement("col")}}, {{HTMLElement("colgroup")}}, {{HTMLElement("table")}}, {{HTMLElement("tbody")}}, {{HTMLElement("td")}}, {{HTMLElement("tfoot")}}, {{HTMLElement("th")}}, {{HTMLElement("thead")}}, {{HTMLElement("tr")}};
  • CSS properties that may be specially useful to style the {{HTMLElement("caption")}} element:
    • {{cssxref("text-align")}}, {{cssxref("caption-side")}}.

{{HTMLRef}}

Revision Source

<h2 id="Summary">Summary</h2>

<p>The <strong>HTML <code>&lt;caption&gt;</code> Element</strong> (or <em>HTML Table Caption Element</em>) represents the title of a table. Though it is always the first descendant of a {{HTMLElement("table")}}, its styling, using CSS, may place it elsewhere, relative to the table.</p>

<div class="note"><strong>Usage note</strong>: When the {{HTMLElement("table")}} element that is the parent of this {{HTMLElement("caption")}} is the only descendant of a {{HTMLElement("figure")}} element, use the {{HTMLElement("figcaption")}} element instead.</div>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row"><a href="/en-US/docs/HTML/Content_categories" title="HTML/Content_categories">Content categories</a></th>
   <td>None.</td>
  </tr>
  <tr>
   <th scope="row">Permitted content</th>
   <td><a href="/en-US/docs/HTML/Content_categories#Flow_content" title="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>A {{HTMLElement("table")}} element, as its first descendant.</td>
  </tr>
  <tr>
   <th scope="row">DOM interface</th>
   <td>{{domxref("HTMLTableCaptionElement")}}</td>
  </tr>
 </tbody>
</table>

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

<p>This element includes the <a href="https://developer.mozilla.org/en-US/docs/HTML/Global_attributes" title="HTML/Global attributes">global attributes</a>.</p>

<dl>
 <dt>{{htmlattrdef("align")}} {{deprecatedGeneric('inline','HTML4.01')}} {{obsoleteGeneric('inline','HTML5')}}</dt>
 <dd>This enumerated attribute indicates how the caption must be aligned with respect to the table. It may have the following values:
 <ul>
  <li><code>left</code>, displayed to the left of the table</li>
  <li><code>top</code>, displayed before the the table</li>
  <li><code>right</code>, displayed to the right of the table</li>
  <li><code>bottom</code>, displayed under the table</li>
 </ul>

 <div class="note"><strong>Usage note: </strong>Do not use this attribute, as it has been deprecated: the {{HTMLElement("caption")}} element should be styled using <a href="/en-US/docs/CSS" title="CSS">CSS</a>. To give a similar effect to the <code>align</code> attribute, use the the <a href="/en-US/docs/CSS" title="CSS">CSS</a> properties {{cssxref("caption-side")}} and {{cssxref("text-align")}}.</div>
 </dd>
</dl>

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

<p>Please see the {{HTMLElement("table")}} page for examples on {{HTMLElement("caption")}}</p>

<h2 id="Specifications" name="Specifications">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', 'tabular-data.html#the-caption-element', '&lt;caption&gt;')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'tabular-data.html#the-caption-element', '&lt;caption&gt;')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML4.01', 'struct/tables.html#h-11.2.2', '&lt;caption&gt;')}}</td>
   <td>{{Spec2('HTML4.01')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</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>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoDesktop("1.0")}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</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>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoMobile("1.0")}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li>Other table-related HTML Elements: {{HTMLElement("col")}}, {{HTMLElement("colgroup")}}, {{HTMLElement("table")}}, {{HTMLElement("tbody")}}, {{HTMLElement("td")}}, {{HTMLElement("tfoot")}}, {{HTMLElement("th")}}, {{HTMLElement("thead")}}, {{HTMLElement("tr")}};</li>
 <li>CSS properties that may be specially useful to style the {{HTMLElement("caption")}} element:
  <ul>
   <li>{{cssxref("text-align")}}, {{cssxref("caption-side")}}.</li>
  </ul>
 </li>
</ul>

<p>{{HTMLRef}}</p>
Revert to this revision