WordPress has changed a lot since its earlier releases. Starting from version 2.7 of WordPress, you can now automatically align images left, right, centered or none, while inserting them in the post,
This works because WordPress automatically generates styles for images based on the alignment chosen by you, and then the image is aligned based on that style definition. For instance, if you center align the image, the output will be,
All the new WordPress themes include styles for these classes. However some old themes doesn’t aligns images automatically because they lack styles for these classes. To fix these themes, add the following code in their style.css file,
margin: 0 0 2px 7px;
margin: 0 7px 2px 0;
This will fix all the issues like images not centered or not aligning correctly in WordPress.
Another new feature that comes with wordpress 2.7 is automatic insertion of image captions while posting the image.
This is a great feature as you can add descriptions or copyright credits as captions. You can use captions even with old WordPress themes but that will not look good since it will just add some plain text below the image which is not aligned properly. To make the captions look great, like this,
Add the following styles to the style.css file of your wordpress theme,
display: block; margin-left: auto; margin-right: auto;
border: 1px solid #ddd; text-align: center; background-color: #f3f3f3; padding-top: 4px; margin: 10px; -moz-border-radius: 3px; -khtml-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px;
margin: 0; padding: 0; border: 0 none;
font-size: 11px; line-height: 17px; padding: 0 4px 5px; margin: 0;
This will fix all the issues like caption text not centered or not aligned properly.
Note that all the new WordPress themes already contain these styles. You need to use them only if the images or captions are not aligned properly.
2 thoughts on “Fix Image And Captions Alignment Issue in Old WordPress Themes”
I’ve been wondering what’s been wrong with this for a long time.
I’m glad it helped :)