Frustrated because your WordPress images always stick to the left like a stubborn magnet? You’re not alone. Whether you’re building a blog, portfolio, or a snazzy recipe site, image alignment matters. Let’s fix it together, step by step. It’s easier than you think!
Why Is This Even Happening?
Before digging into solutions, let’s learn why WordPress images might always align left no matter what you do.
- Theme CSS: Your theme might have some styling that overrides your choices.
- Missing Classes: WordPress uses special classes for alignment. If those go missing, stuff breaks.
- Image Size: If your image is too big, aligning it won’t change a thing.
But don’t worry. We’re going to tackle each of these problems. Ready? Let’s roll.
1. Double-Check the Editor
WordPress lets you set alignment when adding images. But things can slip sometimes.
- Open the post or page.
- Click the image block.
- Look for the alignment toolbar above the image.
- Select center, right, or whatever you want.
If it displays correctly in the editor but not on the front-end, we likely have a theme issue. Keep going!
2. Inspect the Theme CSS
This is where things get a teensy bit geeky, but don’t worry–you’ve got this!
Open your site and inspect the image using Chrome or Firefox’s Dev Tools. You’re looking for something like this:
.aligncenter {
display: block;
margin-left: auto;
margin-right: auto;
}
If this isn’t in your theme’s CSS, then WordPress isn’t sure how to display “aligncenter” images. You just have to add it.
How to Add the Right CSS
Go to your WordPress dashboard and follow these steps:
- Click Appearance > Customize.
- Choose Additional CSS.
- Add this:
.alignleft {
float: left;
margin-right: 1em;
}
.alignright {
float: right;
margin-left: 1em;
}
.aligncenter {
display: block;
margin-left: auto;
margin-right: auto;
}
Click Publish and check your site again. Boom! That might be all you needed.
3. Check Image Size
This one’s sneaky. If your image is wider than your content area, it won’t center or float properly.
To fix this:
- Edit the image in the media library.
- Resize it to be smaller than your content width (maybe around 800px or less).
- Reinsert the image and set the alignment again.
Still stuck with left-aligned images? Let’s check your theme’s HTML support.
4. Make Sure Your Theme Supports Image Classes
WordPress uses alignment classes like alignleft, alignright, and aligncenter. Your theme needs to support them in its layout.
To check that:
- Inspect the image on your page using your browser developer tools.
- Look for the class attribute.
Do you see something like class="aligncenter size-medium wp-image-123"? Great. If not, try removing the image and adding it again using the block editor alignment options.
Also, make sure you’re not using a block or plugin that strips out classes. Some page builders can do that sneakily.
5. Aligning Images Using HTML
If you like doing things old-school, you can align your images with plain HTML.
<img src="imageurl.jpg" class="aligncenter" />
Just make sure your theme has the CSS we added earlier! Without it, the class doesn’t help.
6. Use a Plugin (If You Want a Shortcut)
Plugins are your shortcuts in shiny armor. If all this CSS talk sounds scary, just use a plugin to control alignment.
Try these:
- WP Add Custom CSS: Add custom styles per post or theme.
- Advanced Image Styles: Brings back old image options like margins and borders.
Install, activate, and customize. It’s that easy.
7. Page Builders Can Be Tricky
Using Elementor, Beaver Builder, or WPBakery?
They might override default alignment. In that case:
- Use the page builder’s tools for image alignment.
- Avoid mixing block editor and page builder on the same page.
- Double-check how alignment changes look on mobile.
8. Responsive Design Matters!
Sometimes, images look aligned on desktop but go wonky on mobile. That’s called responsive styling. Make sure your align classes look like this in your CSS:
@media screen and (max-width: 768px) {
.alignleft,
.alignright {
float: none;
display: block;
margin: 0 auto;
}
}
This stops images from floating weirdly on small screens. Thank us later!
9. Don’t Forget the Clearfix
If you float images (left or right), they might mess up your layout after the image. Fix it with a clearfix after the image block.
Add this custom class to your CSS:
.clearfix::after {
content: "";
display: table;
clear: both;
}
Then, in your post, wrap the image in a block with that class. It’ll tidy everything up!
Final Thoughts
Fixing image alignment in WordPress might seem like chasing shadows at first. But with some CSS magic and a little inspection, you can get those images dancing in perfect position.
Here’s a quick recap:
- Use the block editor’s align tools.
- Add or fix the
alignclasses in your theme’s CSS. - Make sure your images aren’t too big.
- Double-check page builders or plugins.
- Use HTML if needed.
Now go align those images like a web design ninja! 🥷























