XML technologies / CSS / CSS Cookbook / Typography for the web / Centring text
(Excerpt from “CSS Kochbuch” by Christopher Schmitt)
Problem
You want to centre text in a paragraph or heading.
Solution
Use the property text-align with the value center:
h3 {
text-align: center;
}
p {
text-align: center;
}Discussion
The value center for the property text-align controls inline content within block elements.
See also
For information about centring other elements on a web page, see the recipe Centring elements on a web page.
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