You are here: Reference > HTML > attributes > align (caption, legend)

align attribute (caption, legend)

Browser support:
Sets the alignment of a caption and legend element relative to a table or fieldSet element.
This attribute is deprecated in HTML 4.01.
  • In Internet Explorer earlier than version 8, use the vAlign attribute to align a caption element to the top or bottom side of a table element.
  • In Firefox, Opera, Google Chrome, Safari and in Internet Explorer from version 8, use the caption-side style property instead.
JavaScript page for this attribute: align. You can find other example(s) there.

Possible values:

String that sets the type of alignment.
One of the following values:
bottom
Aligns to the bottom-center.
center
Aligns to the center. Same as middle.
left
Aligns to the left.
middle
Aligns to the center. Same as center.
right
Aligns to the right.
top
Aligns to the top-center.
Default: this attribute has no default value.

Example HTML code 1:

This example illustrates the use of the align attribute:
<table border="1px">
    <caption align="right">Fruits</caption>
    <tr>
        <td>Apple</td>
        <td>Pear</td>
        <td>Peach</td>
    </tr>
</table>
Did you find this example helpful? yes no

Example HTML code 2:

Recommendation:
<table border="1px">
    <caption style="text-align:center;">Fruits</caption>
    <tr>
        <td>Apple</td>
        <td>Pear</td>
        <td>Peach</td>
    </tr>
</table>
Did you find this example helpful? yes no

Example HTML code 3:

Cross-browser solution to align to the top or bottom:
<table border="1px">
    <caption align="bottom" style="caption-side:bottom;">Fruits</caption>
    <tr>
        <td>Apple</td>
        <td>Pear</td>
        <td>Peach</td>
    </tr>
</table>
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content