CSS text-align Property

Set the text alignment for different <div> elements:

div.a {
text-align: center;
}div.b {
text-align: left;

div.c {
text-align: right;

div.c {
text-align: justify;


Try it Yourself »

More “Try it Yourself” examples below.

Definition and Usage

The text-align property specifies the horizontal alignment of text in an element.

Default value: left if direction is ltr, and right if direction is rtl
Inherited: yes
Animatable: no. Read about animatable
Version: CSS1
JavaScript syntax: object.style.textAlign=”right”Try it

CSS Syntax

text-align: left|right|center|justify|initial|inherit;

Property Values

Value Description
left Aligns the text to the left
right Aligns the text to the right
center Centers the text
justify Stretches the lines so that each line has equal width (like in newspapers and magazines)
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit