Recipe 2.5. Centering Text


Problem

You want to center text within a paragraph or a heading.

Solution

Use the text-align property with the value set to center:

h3 {  text-align: center; } p {  text-align: center; }

Discussion

The center value for the text-align property is designed to control the alignment of inline content within a block element.

See Also

The CSS 2.1 specification for text-align property at http://www.w3.org/TR/CSS21/text.html#alignment-prop; for information about centering various items in a web page, see Recipe 4.3.




CSS Cookbook
CSS Cookbook, 2nd Edition
ISBN: 0596527411
EAN: 2147483647
Year: 2006
Pages: 235

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net