The
text-align
property allows you to set the horizontal alignment for the content relative to the element box. This property can also be attached to the
<col>
or
<table>
element. The 'text-align' property is inherited by all the child elements when applied to the parent element.
The possible values are
Properties | Description |
---|
center | justify | left | right | |
<string> | (only for table cells; eg text-align: ".") |
Note:
Note
The default value is left.
The <col> setting has a greater priority that the <tr> setting.
snippet
<html>
<head>
<style>
span {border:1px solid red;}
</style>
</head>
<body>
<table>
<tr>
<td style="text-align:center">center align text</td>
<td style="text-align:justify">justify align text</td>
</tr>
<tr>
<td style="text-align:left">left align text</td>
<td style="text-align:right">right align text</td>
</tr>
</table>
</body>
</html>