How to Add Image Alignment Styles to WordPress Stylesheets - dummies

How to Add Image Alignment Styles to WordPress Stylesheets

By Lisa Sabin-Wilson

When you upload an image, you can set the alignment for the image as None, Left, Center, or Right. The WordPress theme you’re using, however, may not have these alignment styles accounted for in its stylesheet. If you set the alignment to Left, for example, but the image on the page doesn’t appear to be aligned, you may need to add a few styles to your theme’s stylesheet.

For the purposes of ensuring that you choose the correct alignment for your newly uploaded images, here’s a quick-and-dirty method:

  1. From the Dashboard, choose Appearance→Editor.

    The Edit Themes page opens. All the template files for your active theme are listed on the right side of the page.

  2. Click the Stylesheet template.

    The Stylesheet (style.css) template opens in the text box in the center of the page.

  3. Add your desired styles to the stylesheet.

    These styles are only examples of what you can do. Get creative with your styling.

    Image Alignment Add This to Your Stylesheet (style.css)
    None img.alignnone {float:none; margin: 5px 0 5px
    Left img.alignleft {float:left; margin: 5px 10px
    5px 0px;}
    Center img.aligncenter {display:block; float:none;
    margin: 5px auto;}
    Right img.alignright {float:right; margin: 5px 0
    5px 10px;}