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

Is Wix a WordPress Site? Understanding the Difference

If you’re exploring website builders, you may wonder, “Is Wix a WordPress site?” or even,…

13 hours ago

How to Get to WordPress Dashboard:Quick Access Guide

Are you missing out on the full power of your WordPress site because you’re not…

3 days ago

How to Add Facebook Pixel to WordPress Site: (Easiest Way)

Are you looking to track visitors on your WordPress website, optimize ad performance, and increase…

1 week ago

Is WordPress Easy to Use for Beginners? A Comprehensive Guide

If you’re wondering, “Is WordPress easy to use?” you’re not alone. Many beginners want a…

2 weeks ago

How to Add Shortcode in WordPress: A Beginner-Friendly Tutorial

Shortcodes are an essential part of WordPress. Allowing users to quickly add dynamic content to…

2 weeks ago

How to Embed Facebook Video in WordPress: A Comprehensive Walkthrough

Learning how to embed Facebook video in WordPress can take your site’s content to the…

3 weeks ago