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

  

 

 

 

back to top