You are here: Reference > HTML > attributes > align (div, Hn, p, td, tr, ...)

align attribute (div, Hn, p, td, tr, ...)

Browser support:
Sets the horizontal alignment of the contents in an object.
This attribute is deprecated. Use the text-align 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:
center
Aligns to the center of the available space. Same as middle.
justify
Aligns to the left and right edges.
left
Default. Aligns to the left edge.
middle
Aligns to the center of the available space. Same as center.
right
Aligns to the right edge.
Default: left.

Example HTML code 1:

This example illustrates the use of the align attribute:
<table border="1px" style="width:400px;">
    <tr>
        <td align="center">Contents are aligned to the center.</td>
    </tr>
    <tr>
        <td align="left">Contents are aligned to the left</td>
    </tr>
</table>
Did you find this example helpful? yes no

Example HTML code 2:

Recommendation:
<table border="1px" style="width:400px;">
    <tr>
        <td style="text-align:center;">Contents are aligned to the center.</td>
    </tr>
    <tr>
        <td style="text-align:left;">Contents are aligned to the left</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