XML technologies / CSS / Advanced websites with CSS / CSS property reference / text-align

(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)

The property text-align describes the horizontal alignment of text and other inline content within a block element. Do not confuse it with the properties margin, left or right, which align only block elements.

Inherited: yes

See also: text-align-last, vertical-align

Value

The property text-align supports the following constants:

  • center

  • justify

  • left

  • right

center, left and right align inline content accordingly within its parent block element. justify produces justified text, aligning inline content with both the left and right edges.

Since CSS2, text-align can also align text in tables. With the value “.”, all decimal points in table cells are aligned vertically.

Default value:

depends on the writing system (East Asian, Arabic or Latin) and the browser’s language setting

Compatibility

CSS version: 1 (text alignment in tables only since CSS2)

Works in all CSS-capable browsers. Older versions interpret justify as left (permitted by CSS2). Text alignment in table cells is not supported by any current browser.

Example

The following rule justifies text in body and all its descendants:

body {
 text-align: justify;
}

  

 

 

 

back to top