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:
centerjustifyleftright
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;
}
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg