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

  • Revision slug: Web/HTML/Element/caption
  • Revision title: <caption>
  • Revision id: 493861
  • Created:
  • Creator: kscarfone
  • Is current revision? No
  • Comment Updated 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>
<ul class="htmlelt">
 <li><dfn><a href="/en-US/docs/HTML/Content_categories" title="HTML/Content_categories">Content categories</a></dfn> None.</li>
 <li><dfn>Permitted content</dfn> <a href="/en-US/docs/HTML/Content_categories#Flow_content" title="HTML/Content categories#Flow content">Flow content</a>.</li>
 <li><dfn>Tag omission</dfn> {{no_tag_omission}}</li>
 <li><dfn>Permitted parent elements</dfn> A {{HTMLElement("table")}} element, as its first descendant.</li>
 <li><dfn>DOM interface</dfn> {{domxref("HTMLTableCaptionElement")}}</li>
</ul>
<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