The CAPTION element is an optional table component which displays a caption/title
for the table directly above, below or to either side of the table. The CAPTION
element is contained within the TABLE element, but
is used at the same level as the table row element [TR] is.
Standards Details:
Deprecated in HTML 4.x/XHTML 1.0. Dropped in XHTML 1.1 in favor of CSS
Required? No
Description:
The Align attribute specifies the alignment of the caption relative to the table.
IE also defines extra Align values for horizontal alignment within the Caption.
Values: Top, Bottom - regular attributes Left, Center
and Right (extra IE 2.0+ values for horizontal
alignment of data within the table caption.)
The Table model in HTML (even the Simple Table Model) is easily the most
complex markup structure in HTML. If you have general questions about
this structure see the Table Overview.
Compatibility Tip: To enable Table caption contents to
display well on browsers that do not support tables, it can be helpful
to put either an extra space at the end of each table cell, or even better,
put a <br> element at the end of the
table cell in each row or caption. This should cause no display problems for
browsers that support tables (as there is an implied line break anyway
at the end of every table cell) and should greatly improve readability
on older browsers.
Browser Peculiarities
Internet Explorer changed the intent of the ALIGN attribute in
their 2.0 release. They made the ALIGN attribute indicate
horizontal alignment of text within the caption (like the ALIGN
attribute in TH and TD) rather than the intended use in the
specifications to indicate alignment of CAPTION content position
relative to the table. The relative-to-table attribute assigned
to this duty was a new VALIGN attribute. The reference for the
3.0 version of Internet Explorer does not list the VALIGN attribute
anymore and it would appear that it only supports the W3C model, but
testing indicates that IE still supports the VALIGN attribute syntax as well.
The W3C Table model lists two additional attributes to ALIGN:
Right and Left to allow
Captions to be placed to the right or left side of a table.
Popular browsers basically do not support this behavior. Interestingly,
Opera 4-6.x DID attempt to render these attributes on the right/left
side of a table, but it did so very poorly - often rendering the caption
outside the page window on the left side or over other content on the
right. It retracted support for these values in Opera 7.x.
[Test]
The Tables specification says the CAPTION element should always
come at the beginning of a table structure (this is to ensure proper
rendering in progressive table display.) I have yet to see a
browser misbehave if the CAPTION is placed say, just before the end
of a table structure. It seems that as long as CAPTION is used at
the same level as a table row hierarchy element, things will
render fine.
[Tests: 1,
2]
Opera 3.5+: CSS does not directly apply or inherit to this element.