Syntax |
selector {text-align: value;}
- value is specified by using one of the following keywords: left, right, center, justify, or inherit.
|
Usage |
The text-align property is used to specify the horizontal alignment of inline-level content such as text and images.
This property is specified by using a keyword according to the syntax shown above.
CSS Example: The text-align properties are set to right, justify, and center. h1 {text-align: right;}
p {text-align: justify;}
div {text-align: center;}    |
Keywords |
- left - Aligns the content to the left side.
- right - Aligns the content to the right side.
- center - Centers the content.
- justify - If possible, both the left and right sides are aligned by adjusting the width of the content. For example, the width of a line of text can be adjusted by varying the word spacing.
- inherit - The inherit keyword is used to specify that the value for this property should be taken from the parent element. If inherit is used with the root element, then the initial value for this property will be used.
|
Applies To |
Block containers |
Inherited |
Yes |
Initial Value |
Depends on the value of the direction property. If the direction property is set to ltr, then the text will be aligned to the left side. If the direction property is set to rtl, then the text will be aligned to the right side. |