Property Description
The text-align property sets the horizontal alignment of text in an element.
This property has the following syntax:
text-align: left|right|center|justify|initial|inherit;
Property Values
Value | Description |
---|---|
left | (default if direction=ltr) Aligns the text to the left |
right | (default if direction=rtl) Aligns the text to the right |
center | Centers the text |
justify | Stretches the lines so that each line has equal width |
initial | Specifies that the value of the property should be set to the default value |
inherit | Specifies that the value of the property should be inherited from the parent element |
Examples
The following example shows the basic use of this property:
<p style="text-align:left">text-align:left</p>
<p style="text-align:right">text-align:right</p>
<p style="text-align:center">text-align:center</p>
This produces the following result:
text-align:left
text-align:right
text-align:center
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
1.0 | 1.0 | 3.0 | 1.0 | 3.5 |
Miscellaneous Information
Inherited: | Yes |
---|---|
Defined In: | CSS1 |
Default Value: | left if direction is ltr, and right if direction is rtl |