Recipe 8.3. Setting the Style for Caption


Problem

You want to set the style for the description of a table.

Solution

Use the caption element selector to stylize the caption:

table caption {     font: 1.5em Georgia, "Times New Roman", Times, serif;      padding: 1em; }

Discussion

Captions are used to describe the contents within a table and should be placed after the opening table element and before another table element like thead or TR:

<table  summary="List of products in your shopping cart.">  <caption>Shopping Cart Listing - <strong>Subtotal: $45.16</strong>;  changed quantities? <input type="submit"  value="Update price(s)" /></caption>  ... </table>

Browsers may vary in how to render the caption element. However, caption will always be displayed by any browser, can be styled via CSS, and is the most accessible method of displaying a table caption.

See Also

The HTML 4.01 specification for caption at http://www.w3.org/TR/html4/struct/tables.html#h-11.2.2.




CSS Cookbook
CSS Cookbook, 2nd Edition
ISBN: 0596527411
EAN: 2147483647
Year: 2006
Pages: 235

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net