XML technologies / CSS / CSS Cookbook / Typography for the web / Displaying justified text
(Excerpt from “CSS Kochbuch” by Christopher Schmitt)
Problem
You want justified text, aligned with both the left and right margins, as shown in the following figure.
Figure: The paragraph is justified.
Solution
Use the property text-align with the value justify:
P {
width: 600px;
text-align: justify;
}Discussion
How well does justification work on the web? According to the specification for CSS 2.1 this depends on the algorithms used by browser developers. There is no standard, so justified text differs between browsers even when they support justification in principle. The following browsers provide good support for text-align: justify;: Internet Explorer 4+ for Windows, Internet Explorer 5 for Macintosh, Mozilla Firefox 1.5+, Safari and Opera 3+. Justified text is easy to read in these browsers. In others, it may look worse because large gaps can appear between words.
See also
The CSS 2.1 specification for the text-align property.
Copyright of the German edition © 2007 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “CSS Kochbuch” 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.
O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln