CSS text-alignProperty
Example
h1, h2, and h3 elements set the text alignment:
h1 {text-align:center}
h2 {text-align:left}
h3 {text-align:right}
Try it Yourself »
More examples at the bottom of this page.
Property definition and usage instructions
The text-align property specifies the horizontal alignment of text in an element.
| Default value: | If the direction attribute is ltr, the default value is left; if the direction attribute is rtl, the default value is right. |
|---|---|
| Inherited: | yes |
| version: | CSS1 |
| JavaScript Syntax: | object.style.textAlign="right" |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
The number immediately preceding -webkit-, -ms-, or -moz- is the first browser version that supported the prefixed property.
| Property | |||||
|---|---|---|---|---|---|
| text-align | 1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
Property value
| Value | Description |
|---|---|
| left | Aligns the text to the left. Default value: determined by the browser. |
| right | Aligns text to the right. |
| center | Aligns text to the center. |
| justify | Justifies text to create an aligned text effect on both sides. |
| inherit | Specifies that the value of the text-align property should be inherited from the parent element. |
More Examples
More examples of advanced text alignment.
This example demonstrates a more advanced example of text alignment.
Related Articles
CSS Tutorial:CSS Text
other extensions