Sizlopedia

Categories ▼

Can’t Align Images in Wordpress? Try this Fix

Wordpress 2.5+ introduced a new image gallery system and correspondingly a new way to align images which was relatively intricate compared to the old one.

The main problem I faced using the new system until now was that I couldn’t make Wordpress align the images properly for me. I thought I was the only one facing this problem but a helpful post by Daniel made it clear that there are perhaps more users facing the same problem.

I am sharing the fix just in case someone comes searching through to find a fix for this problem. All you need to do is add the following piece of CSS code to your theme stylesheet and you are good to go.

img.centered {
display: block;
margin-left: auto;
margin-right: auto;
}

img.alignright {
padding: 4px;
margin: 0 0 2px 7px;
display: inline;
}

img.alignleft {
padding: 4px;
margin: 0 7px 2px 0;
display: inline;
}

.alignright {
float: right;
}

.alignleft {
float: left;
}

This will make Wordpress aware of all alignments.

Related Articles

Comments

Thx very much.
I need it!

Thanks :D I changed from Wordpress editor to WLW because of Image alignment problem..

Testing this code.. :)

Xtd

Thanks, worked wonders!
My wife was almost about to give up on our family blog so this saved my day!

I was looking for the same fix. Thanks!

Glenn Kilpatrick

Hi guys. I checked my css and this is present. The problem I have is slightly different. I cant stop the text from wrapping around an image.

Any help please ??

Thanks so much for this. I should have “gotten it” on my own but . . . you saved me from tearing out my gray hair.

Janne Toft Jensen

Thank you so much! Fixed one of two remaining problems on my blog :-)

You wouldn’t happen to know how to make the page navigation work (appear) in the Cutline theme when using the 2.6.3 version of Wordpress - would you…?

Leave a Comment

Name: (Required)

E-mail: (Required)

Website: (Optional)

Comment: