
Responsive website images should look sharp on a wide monitor without forcing someone on a phone to download an unnecessarily large file. A page can resize a photo with CSS and still transfer the full desktop image. The fix is to give the browser suitable image options and accurate information about how much space the image will occupy.
Why resizing an image with CSS is not enough
Imagine a gallery card that displays a photo at 320 pixels wide on a phone but downloads a 2400-pixel original. The photo fits the layout, yet the visitor may wait for bytes they never needed. High-density screens complicate the choice: a 320-pixel display slot may benefit from an image wider than 320 pixels to remain crisp.
Responsive images let the browser choose among versions based on the display slot, pixel density and other conditions. They can reduce image transfer and help important page content appear sooner. They are not a substitute for compressing images or choosing a sensible format.
How srcset and sizes work together
The srcset attribute lists available files and their actual widths. The sizes attribute tells the browser the expected display width at different viewport sizes. The ordinary src remains a fallback.
<img
src="/images/portfolio-960.jpg"
srcset="/images/portfolio-480.jpg 480w,
/images/portfolio-960.jpg 960w,
/images/portfolio-1440.jpg 1440w"
sizes="(max-width: 700px) 100vw, 50vw"
width="960"
height="640"
alt="A portfolio project shown on a desktop screen">
In this example, a narrow viewport gets a full-width image slot, while a wider viewport uses roughly half the viewport. The browser can then choose a file appropriate to the slot and screen density. The widths after each filename must match the real file dimensions. The sample values are illustrative; real layouts may include padding, fixed maximum widths or multiple columns.
If sizes says 100vw when a card actually occupies only one-third of a desktop page, the browser may choose a larger image than necessary. Check the layout rather than copying a generic value.
When to use the picture element instead
Sometimes a smaller copy of the same photo is not enough. A wide hero photo may show a person clearly on desktop but crop their face on a narrow phone. This is called art direction: using a different crop or composition for different layouts.
The HTML <picture> element can select a mobile-specific crop and retain a fallback <img>. Use it when the composition genuinely needs to change, not merely to produce a smaller download. MDN's responsive images guide explains both resolution switching and art direction.
What to check in WordPress and custom websites
WordPress already generates several image sizes and commonly adds srcset and sizes to image markup. That does not guarantee the theme's layout hints are accurate. Custom themes, page builders, background images and manually inserted markup deserve a closer look. The WordPress developer documentation explains its native behavior.
For a custom site, define a few image widths that correspond to real layout slots. Keep the source images at matching aspect ratios when they are alternatives for the same composition. If a hero needs a different crop, treat that as a separate art-direction decision. A thoughtfully built responsive layout is part of website development, not just a final image-compression step.
How to test responsive image loading
- Open the page in browser developer tools and select a narrow mobile viewport.
- In the Network panel, inspect the actual image file requested, its dimensions and transfer size.
- Compare the file width with the displayed slot and test a high-density device setting.
- Repeat on tablet and desktop widths, especially where the grid changes columns.
- Inspect the largest visible image and check whether it loads promptly. Do not automatically lazy-load a prominent above-the-fold hero.
- Run a performance audit, then verify the specific files and layout rather than relying only on an overall score.
Also give images explicit width and height or an equivalent aspect ratio to reserve space while loading. Choose descriptive alt text for meaningful content and empty alt text for purely decorative images.
Common responsive image mistakes
One giant source file: CSS scales the image visually but cannot recover the unnecessary download. Generate genuinely smaller alternatives.
Incorrect sizes hints: The browser is told a slot is wider than it really is. Match the attribute to the rendered layout and breakpoints.
Blurry images: An image suitable for a standard-density screen may not be sufficient for a high-density display. Include an appropriate larger candidate without making every device fetch it.
Unhelpful mobile crop: The main subject disappears at narrow widths. Use art direction rather than hoping one centered crop works everywhere.
Assuming WordPress handles everything: Check generated markup and network requests in the actual theme; automatic markup still depends on available source sizes and layout assumptions.
A practical next step
Start with the three largest images on your most visited page. Record the width they display at on mobile and desktop, inspect which files are downloaded, and correct the worst mismatch first. If your templates need a broader responsive rebuild, DesDevSol can help plan and implement it.