< css‎ | properties
Jump to: navigation, search


This article is Ready to Use.

W3C Working Draft


The text-align CSS property describes how inline content like text is aligned in its parent block element. text-align does not control the alignment of block elements itself, only their inline content.

Overview table

Initial value start, or a nameless value that acts as left if direction is ltr, right if direction is rtl, if start is not supported by the browser.
Applies to block containers
Inherited Yes
Media visual
Computed value as specified, except for the match-parent value which is calculated against its parent's direction value and results in a computed value of either left or right
Animatable No
CSS Object Model Property textAlign


  • text-align: <string>
  • text-align: center
  • text-align: end
  • text-align: justify
  • text-align: left
  • text-align: match-parent
  • text-align: right
  • text-align: start
  • text-align: start end


The same as left if direction is left-to-right and right if direction is right-to-left.

The same as right if direction is left-to-right and left if direction is right-to-left.

The inline contents are aligned to the left edge of the line box.

The inline contents are aligned to the right edge of the line box.

The inline contents are centered within the line box.

The first occurrence of the one-char string is the element used for alignment. the keyword that follows or precedes it indicates how it is aligned. This allows to align numeric values on the decimal point, for instance.

The text is justified. Text should line up their left and right edges to the left and right content edges of the paragraph.

Similar to inherit with the difference that the value start and end are calculated according the parent's direction and are replaced by the adequate left or right value.

start end
Specifies start alignment of the first line and any line immediately after a forced line break; and end alignment of any remaining lines not affected by text-align-last.


This just shows the four possible types of text-alignment.


<p class="left"> This paragraph is aligned to the left. </p>

<p class="centered"> This paragraph is centered. </p>

<p class="right"> This paragraph is aligned to the right. </p>

<p class="justified">This paragraph needs to be really long in order to show how to justify text. It only works because we set a width for this paragraph though.</p>

View live example


.left { text-align: left;}
.cenetered{ text-align: center;}
.right { text-align: right;}
.justified { width: 200px; text-align: justify;}


The standard-compatible way to center a block itself without centering its inline content is setting the left and right margin to auto, e.g.: margin:auto; or margin:0 auto; or margin-left:auto; margin-right:auto;

Related specifications

Specification Status Related Changes
CSS Text Level 3 Working Draft Added the start and end keyword. Changed the unnamed initial value to start (which it was). Added the <string> value, the match-parent value and the start end double value.

See also

Other articles


This article contains content originally from external sources.

Portions of this content come from the Mozilla Developer Network cc-by-sa-small-wpd.svg: Article

Portions of this content come from the Microsoft Developer Network: Article