Categories: Uncategorized

How To Fix WordPress Images That Won’t Align Properly

WordPress provides built-in functionality to align images left, right, and center, but it relies on your theme to render those images properly.

If you find that your images are not aligning correctly in your theme, you can solve this by adding a few lines of CSS to your theme’s stylesheet (preferably using a child theme), or to the Additional CSS section of the Customizer:

.aligncenter, div.aligncenter {
display: block;
margin-left: auto;
margin-right: auto;
}
.alignleft {
float: left;
}
.alignright {
float: right;
}

Once you’ve added this, you should find that your images begin aligning as intended.

If you have any questions, feel free to leave them in the comments below!

Brad Merrill

Brad Merrill is the CEO of Merrill Media and Editor in Chief of GigaPress.

View Comments

  • Live Action Hero says:

    It doesn't work... Images from Flickr stay alined left...

    • Brad Merrill says:

      This code is for images that have been added directly through the WordPress editor, using the default aligncenter, alignleft, and alignright CSS classes. You may be able to tweak this for your use case. What method are you using to embed your Flickr images?

      • Live Action Hero says:

        I simply embed images in the blog with WP blocks (Flickr or Image). But if you do it straight away, it doesn't work: images stay aligned left. Always.
        I managed to solve the issue in this way: you need to copy and paste in the embedding box only the TRUE link of the originally upped image. NOT THE SHORT LINK PROVIDED BY FLICKR IN THE SHARE COMMAND BOX (or the link in the browser). It is usually an image with an alphanumerical name that replaced the original name of your image. You get it from the BBEdit code box of Flickr. Sometimes it is tricky to insulate it for copy/paste in the box itself. You have an easier life copying the entire code in a text-editor and recopying only the link from there. That works without problems, and you can align it with WP commands at your discretion.

Recent Posts

How to Set X-Frame Options to Allow-From in WordPress: A Complete Guide

Did you know that your WordPress site might be vulnerable to clickjacking attacks if proper…

2 days ago

A Complete Step-by-Step Guide on Where to Put Google Analytics Code on WordPress

Have you ever wondered how many people visit your website, what pages they spend the…

1 week ago

How to Install WordPress on GoDaddy: Easy Guide for Beginners

Ready to launch your WordPress website? Install WordPress on GoDaddy and take advantage of one…

2 weeks ago

How to Reset WordPress: Step-by-Step Guide for Beginners

Are you looking to reset a WordPress site and start fresh? Reset a WordPress Site…

3 weeks ago

WordPress vs. Wix: Which Platform Is Right for You?

Ready to build your online presence? Choosing the right platform between Wix vs. WordPress is a crucial first…

3 weeks ago

How to Change Favicon in WordPress: A Step-by-Step Guide

Changing your favicon in WordPress is a small yet powerful way to improve your website’s…

3 weeks ago