HTML and CSS Reference
Table caption for the KPAF programming schedule
Although table captions might lie outside of the borders of a Web table, they are still
part of the Web table's structure. This means that they inherit any styles associated with
the table. For example, if you create a style for the table element that sets the font color
to red, the caption text also will be displayed in a red font. You'll explore how to apply
styles to table captions in the next session.
Aligning a Caption with HTML
A table caption is treated as a block element and by default placed directly above the
table, but you can change the placement of the caption in HTML using the following
<caption align=” position ”>content</caption>
In this code, position can be either top , bottom , left , or right , to place the cap-
tion above, below, or to the left or right sides of the table, respectively.
The interpretation of the left and right values is not consistent among the major
browsers. Firefox places the captions to the left or right of the Web table. Internet
Explorer and Opera still place the caption above the table, but horizontally align the cap-
tion text to the left or right. Safari and Chrome ignore the align attribute altogether.
The align attribute is another example of a presentational attribute that has been
deprecated in favor of style sheets, though you'll still often find it used on Web sites,
both old and new. However, the best practice is to align the caption not in the HTML file,
but in a style sheet using the caption-side property.