Skip to content
∞ INFINITE LIVES
  • Services
  • Domains
  • Work
  • Blog
  • Free Tools
  • Marketplace
  • About
Client login WhatsApp me
► 8th October 2024  |  Web  |  3 min read

How to Ensure Your WordPress Featured Images Fit Perfectly Within Their Container

Make WordPress Featured Images Fit Perfectly

Featured images are an essential part of any WordPress website. They act as the visual representation of your post or page and significantly contribute to the overall user experience. However, one common issue site owners face is featured images that don’t fit properly within their containers. Either they overflow, appear too small, or don’t align perfectly with the page layout.

In this article, we’ll explain why ensuring your featured images are scaled and aligned correctly is important for your website’s design and user experience. We’ll also show you a quick CSS solution to centralise your featured images, add a clean gap around them, and ensure they fit perfectly within their container.

Why Featured Image Alignment Matters

  • Aesthetic Appeal: A featured image that fits perfectly within its container, with some spacing around it, looks more professional and visually pleasing.
  • Improved User Experience: If images are improperly sized or misaligned, it can make the page look cluttered or break the flow of content, which can negatively impact user experience.
  • Mobile Responsiveness: Images that are not properly scaled may not adapt well to different screen sizes. Proper scaling and alignment ensure your featured images look great on all devices.

The Solution: Simple CSS to Fit and Centre Your Featured Image

To fix this issue, we can apply some simple CSS that ensures your featured images take up 100% of their container’s width, while remaining centralised and giving them a small padding for a professional, clean look.

Here’s the CSS you can use:


.post-thumbnail img,
.wp-post-image {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
    margin: 0 auto; /* Ensures the image is centred */
    padding: 10px;  /* Adds a small gap around the image */
    box-sizing: border-box; /* Ensures the padding doesn't affect the image width */
}

How to Add This CSS to Your WordPress Site

  1. Navigate to the WordPress Customiser:
    • In your WordPress dashboard, go to Appearance > Customize.
  2. Find the Additional CSS Section:
    • In the Customiser menu, select Additional CSS.
  3. Add the Code:
    • Copy and paste the CSS code above into the editor.
  4. Publish Your Changes:
    • After adding the CSS, click Publish to apply the changes to your site.

What This CSS Does:

  • Width and Height: The width: 100% ensures that the image takes up the full width of its container, while height: auto maintains the aspect ratio.
  • Object Fit: The object-fit: cover property makes sure the image covers the entire container without distortion or stretching.
  • Centred Alignment: margin: 0 auto; centres the image horizontally.
  • Padding: The padding: 10px; adds a clean gap around the image to avoid it sticking to the edges of its container.
  • Box Sizing: The box-sizing: border-box; ensures the padding is included in the image’s total width, preventing any overflow.

Final Result

Once you’ve added this CSS, your featured images will:

  • Fit perfectly within their container.
  • Be centred horizontally on the page.
  • Have a clean, consistent gap around them for a professional look.
  • Be fully responsive, ensuring a great appearance across all screen sizes.

Conclusion

Featured images play a significant role in how your website looks and functions. With just a few lines of CSS, you can ensure that your images fit perfectly, are centred, and have a clean gap around them. This simple solution not only improves the aesthetics of your site but also enhances the overall user experience.

If you want your website to look polished and professional, this CSS tweak is a quick and easy way to achieve that! Let us know if you try it out and how it works for your site.

◄ Previous Post Why Getting 100% (or Close) on All-in-One SEO Audit Checklist is Crucial for Search Engine Success Next Post ADHD and Late-Night Creativity. Finding The Balance ►

► RELATED POSTS

A scrambled Rubik's Cube on a white background
Web
► 26th November 2026

Sort My Cube: I Built a Free Rubik’s Cube Solver That Talks You Through Every Turn

The Hair by Maria homepage
Web
► 20th November 2026

Weekly round-up: 13 November to 20 November 2026

Blogging
Web
► 14th May 2025

Blogging: It’s Not Just Writing Content

▲
► WHO WROTE THIS

Infinite Lives Group

Websites, software, smart tech and the stories behind them. Built in the UK since 1997.

About Infinite Lives ►

Featured Project

H.A.R.R.I
Software
► 2026
View case study ►

Recent Posts

  • Rebuilding The Clearance Team: a house clearance website people can trust
  • ADHD Brain Fire: 16 Projects in a Week and I Couldn’t Make My Bed
  • Item in a Box Locator Grew Up: Meet BoxLo!!
  • Weekly round-up: 20 November to 27 November 2026
  • Sort My Cube: I Built a Free Rubik’s Cube Solver That Talks You Through Every Turn

For Sale

g14thc.com
Cannabis / CBD
Domain only
£25
View listing ►

Categories

  • Arcade & Retro
  • Business
  • Life
  • Web
Infinite Lives Group
  • Services
  • Domains
  • Digital PR
  • Recent Work
  • Blog
  • Marketplace
  • Find us on Google
  • Support
  • Server status
  • Contact
  • Privacy
  • Terms
  • LinkedIn
  • Instagram
  • TikTok
  • YouTube
1up@infinitelives.co.uk

Registered Apple Developer · Google Play Developer · Amazon Alexa Developer

© 2025 - 2026 Infinite Lives

We use Google Analytics cookies to count visits and improve the site. OK with that?