CSS text-align property

Description

CSS text-align property represents how to align the inline-level content along the inline axis if does not fit within a line box.

It does not affect the last line of text in a box.

Syntax

text-align : start | end | left | right | center | justify | match-parent

Property values

startDefault

It aligns the content at the start of inline axis.

text-align: start;

end

It aligns the inline-level content at the end of inline axis.

text-align: end;

left

It aligns the inline-level content at the left side of line box.

text-align: left;

right

It aligns the inline-level content at the right side.

text-align: right;

center

It aligns the inline-level at the center of inline axis.

text-align: center;

justify

It justifies the content according to the method specified by the text-justify i.e. it exactly fills the line axis except the last line which is aligned at start.

text-align: justify;

match-parent

In this case, the current element inherits the value of text-align from the parent element.

If the value of text-align property for the parent element is center, the value of text-align property for the current element will also be center. -webkit- prefix resolves the browser compatibility issues.

text-align: -webkit-match-parent;

Applicable to

It applies to all elements

#CSS digger
Was this article helpful?

 
We are observing the behavior of text align property. We are observing the behavior of text align property.
×

Ctrl+D