Browse By Name
HTMLCSSJavaScriptAppendix
You are here: Reference > HTML > attributes > align (caption, legend)

align attribute (caption, legend)

A A Font size Print Content Add new content Share Share
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, Safari and in Internet Explorer from version 8, use the caption-side style property instead.
If you want to use this element dynamically, visit the 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.
middle|center
Aligns to the center.
left
Aligns to the left.
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="1">
    <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="1">
    <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="1">
    <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