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 tabletop
, displayed before the the tableright
, displayed to the right of the tablebottom
, displayed under the table
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}}