This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.



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
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
CSS Object Model Property


  • 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

CSS Text Level 3
Working Draft

See also

Other articles


  • Mozilla Developer Network cc-by-sa-small-wpd.svg: Article

  • Microsoft Developer Network: Article