Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

2. Web Typography > Centering Text

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.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint