CSS text-align Property

❮ Previous Reference Next ❯

Example

.example1 {
  text-align: center;
}

.example2 {
  text-align: left;
}

.example3 {
  text-align: right;
}

.example4 {
  text-align: justify;
}





Hello World!

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

Lorem Ipsum is simply dummy text of the printing and typesetting industry.


Meaning

The text-align property sets the horizontal alignment of elements.

Default value:left if direction is 'ltr',
right if direction is 'rtl'
Inherited:Yes
Animatable:No
Version:CSS1
JavaScript syntax:
object.style.textAlign="left|right|center|justify|start|end|match-parent|initial|inherit|revert|revert-layer|unset";



Standard Syntax

text-align: left|right|center|justify|start|end|match-parent|initial|inherit|revert|revert-layer|unset;



Browser Support

The numbers in the table specify the first browser version that fully supports the property.




Status







Property Values

The following table describes the values of this property.

Value Description
left Aligns the text to the left.
right Aligns the text to the right.
center Aligns the text to the center.
justify The text is justified.
start The same as left if direction is left-to-right and right if direction is right-to-left.
end The same as right if direction is left-to-right and left if direction is right-to-left.
justify-all Experimental. Same as justify, but also forces the last line to be justified.
match-parent Similar to inherit, but the values start and end are calculated according to the parent's direction and are replaced by the appropriate left or right value.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element animation-delay property.
revert Reverts the cascaded value of the property from its current value to the value the property
revert-layer Rollback styles to the ones specified in previous cascade layers.
unset Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not.



Default CSS Property Values

selectors {
  text-align: (left if direction is 'ltr', right if direction is 'rtl');
}
❮ Previous Reference Next ❯