The short answer

Use srcset to list image files with their actual pixel widths and sizes to describe the displayed slot at each layout breakpoint. Keep a working src fallback. Check the rendered width and selected currentSrc in a fresh browser visit, including the display pixel density.

On this page
  1. Start with the displayed width
  2. Export one image at three widths
  3. Match the hint to your real layout
  4. Check the selected source in a fresh visit
  5. Sources & further reading

Start with the displayed width

A responsive image needs two pieces of information. srcset lists the available files and their widths. sizes describes the space the image will occupy at different viewport widths. The browser uses that information, including the display's pixel density, to select a source.

First measure the image's place in your layout. A photo in a narrow article column needs different size information from a full-width banner, even on the same screen. CSS controls the displayed box. The sizes attribute supplies information for source selection.

The example below uses a fictional craft shop with a single-column course page. The image has 16 CSS pixels of space on each side on small screens and stops growing at 720 pixels.

Export one image at three widths

Suppose the shop has a photograph of a small wooden loom. Export the same composition at 360 × 240, 720 × 480 and 1440 × 960 pixels. The files have the same aspect ratio. The numbers in their width descriptors must match their actual pixel widths.

Here is the corresponding HTML. The paths are illustrative and need to point to your own exported files.

<div style="width: min(720px, calc(100vw - 32px)); margin-inline: auto;">
  <img
    src="/images/loom-720.webp"
    srcset="/images/loom-360.webp 360w,
            /images/loom-720.webp 720w,
            /images/loom-1440.webp 1440w"
    sizes="(max-width: 752px) calc(100vw - 32px), 720px"
    width="1440"
    height="960"
    alt="A small wooden loom holds a blue woven sample."
    style="display: block; width: 100%; height: auto;">
</div>

At a viewport width of 390 CSS pixels, this container is 358 pixels wide. At 1440 pixels, it is 720 pixels wide. The sizes expression describes those same widths. The 752-pixel breakpoint is the 720-pixel cap plus the 32 pixels of side space.

The width and height values describe the image's proportions, while CSS lets its displayed dimensions adapt. Keep a usable src URL as well. Google's image guidance recommends it as a fallback for clients that don't understand responsive image attributes.

Match the hint to your real layout

If you copy this markup into a two-column card grid, rework both the container CSS and sizes. Leaving the hint at the full viewport width could make the browser choose a larger file than the smaller card needs.

Check the real template at its breakpoints. Measure the image box after side padding, gaps and maximum widths are applied. Then describe those widths in sizes. When several media conditions are listed, their order matters because the browser uses the first matching entry.

A denser display may need a larger source for the same CSS width. A larger selected file on a phone can therefore be reasonable. Inspect the box, pixel density and selected file together before deciding that the markup is wrong.

Check the selected source in a fresh visit

Open the page in a browser at a narrow viewport and select the image in the Elements inspector. In Chrome DevTools, $0.currentSrc gives the selected image URL. $0.getBoundingClientRect().width gives its displayed width.

Open the fallback URL directly and confirm it loads an image. Check the exported files' actual pixel dimensions against each width descriptor. Repeat the page check at a wide viewport using a fresh visit or disabled cache. Browsers can consider resources they already have, so shrinking a page after it loaded a large image can make selection harder to interpret. Confirm the image actually loaded too. A value in currentSrc alone doesn't prove a successful download.

For this example, we checked the layout and source selection in fresh Chromium contexts with JavaScript disabled and synthetic image files at the declared dimensions. We also checked the fallback after removing the responsive attributes. Those tests cover the sample markup. On your site, check the actual exported photographs and their detail at the displayed size.

Use the lazy-loading guide to decide when a later image should load, and the alt-text examples to describe the photograph in its context. Keep source selection, loading time and text alternatives as separate decisions when reviewing an image.

Sources & further reading

Primary references checked Nov 23, 2026. Platform guidance can change.

  1. HTML Standard for image source selection
  2. MDN responsive images guide
  3. Google image SEO guidance
  4. HTMLImageElement currentSrc reference
  5. Chrome DevTools console utilities

AI-assisted research and writing. Learn about our editorial standards.

Suggest a correction ↗