tadam logo

HTML <caption> align Attribute

Example

A table with aligned caption element:
<p>align="left":</p>
<table border="1">
  <caption align="left">Monthly savings</caption>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>

<p>align="right":</p>
<table border="1">
  <caption align="right">Monthly savings</caption>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>

<p>align="top":</p>
<table border="1">
  <caption align="top">Monthly savings</caption>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>

<p>align="bottom":</p>
<table border="1">
  <caption align="bottom">Monthly savings</caption>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>
The output of the code above will be:

Compatibility Notes

The align attribute of <caption> is deprecated, and is not supported in HTML 4.01 Strict / XHTML 1.0 Strict DTD.

A deprecated element or attribute is one that has been outdated.
Deprecated elements may become obsolete in the future, but browsers should continue to support deprecated elements for backward compatibility.

CSS syntax: <caption style="caption-side:left;">

Note: The CSS caption-side property is not very well supported in the major browsers!

CSS Example: Position a table caption.

In our CSS tutorial you can find more details about the caption-side property.

Definition and Usage

The align attribute defines the alignment of a caption element.

This attribute should align the caption as a block element to the left, right, above, or below a table.

Browser Support

The align attribute is not properly supported in any of the major browsers, except Firefox.

Note: The "top" and "bottom" values are supported in all browsers above. The "left" and "right" values are not supported at all in Chrome or Safari, and Internet Explorer and Opera only aligns the text inside the caption (not the entire caption element).

Syntax

<caption align="value">

Attribute Values

ValueDescription
leftThe caption is at the left of the table
rightThe caption is at the right of the table
topThe caption is at the top of the table (this is default)
bottomThe caption is at the bottom of the table
Was this information helpful?
   

Comments