Centering Text with CSS

Centering text and other elements can easily be done with the CSS text-align property. It can be applied to a division, the p tag – pretty much any block-level element.

Applying this to an internal or external stylesheet:

p {text-align: center;}

or this to inline styling:

<p style="text-align: center;">This is centered text</p>

will center your text.


This post was written by:

This entry was posted on Tuesday, June 29th, 2010 at 12:29 am and is filed under CSS Basics, CSS Misc, CSS Page Layouts, Killer CSS Tips and Tricks. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

7 Responses to “Centering Text with CSS”

  1. Vineet says:

    Additionally, you may like to center the para occupying part of the webpage to the center. You can do so by:
    add following lines
    p {
    width: 100px; /*whatever the width of your paragraph is*/
    margin: 0 auto;

  2. hareesh says:


  3. Yuvarajpadhyaya says:

    Thank u for creating such useful website…:)

  4. Web Design in Dehradun says:

    if i use
    div {
    width: 100px; /*whatever the width of your paragraph is*/
    margin: 0 auto;
    for my website it does not work in internet explorer why?

  5. It works in IE versions 6 and up. If you’re still on 5, it’s time to upgrade. If you absolutely have to make it work for <6, center a wrapper.

    If the IE version is not the issue, you have some other error. Post your question along with a link to the page, or at the very least copy and paste your css and the html in the Killersites Forum:

  6. Dahlia says:

    Is there also somewhere on this site where I can learn css jargon, because I don’t understand half of what you’re saying.

  7. admin says:

    Sure, just start with the basic tutorial:

    Or you can take my basic web design course where I go into CSS basics in detail: