CSS text-align property syntax and examples

The CSS text-align property is used to align inline elements within the element to which it applies. This feature is only applicable to block containers.

CSS text-align property
CSS text align property

Syntax

text-align: left|right|center|justify|initial|inherit;
left The text aligns to the left.
right The text aligns to the right.
center Center the text.
justify The text sits on two sides. (Justify the text)
initial This will return the default values. Read more initial
inherit This property inherits from a parent element. Read more inherit

text-align Examples

div {
text-align: center;
}

p {
text-align: left;
}

h1 {
text-align: right;
}