Serve the Image Size the Page Actually Needs
Responsive image markup works when layout width, source candidates, and art direction agree.

To serve the image a page actually needs, describe the image slot's expected width, give the browser several correctly labeled files, and check which one a real layout selects. Use width-based candidates when a photograph changes physical size across layouts, and let the browser consider the device's pixel density. Use alternative crops only when the composition needs to change. A desktop banner, a mobile lead, and a small article card can all show the same subject while needing different bytes and sometimes different framing.
Start where the image is placed
An image can occupy 400 CSS pixels on a phone, 680 in a reading column, and 300 in a desktop grid. Measure that element instead of assuming the largest viewport always contains the largest version. A common error begins when a developer omits sizes for width-based candidates. In a usual width-descriptor case the browser can end up assuming a source size of 100 viewport-width units, which is very different from a 300-pixel card inside a wide desktop page. The CSS still displays the card at the right width. The downloaded resource can be larger than the card needs. HTML Standard on responsive image source selection
Start with the CSS container. If the article has a centered maximum width with sixteen pixels of left and right margin on a narrow screen, its featured image might fill the width available after subtracting those gutters. On a wide screen an adjoining column may cap that same image at 720 CSS pixels. Describe those conditions with source size expressions that parallel the layout. In sizes, earlier matching conditions are considered first, followed by an unconditional last entry if you provide one. Keep the source sizes and CSS written near each other in the component so someone who changes the grid remembers to revisit the resource hint.
Compare intended slot width with the computed result near each layout transition. A 767-pixel viewport can display the image wider than a 769-pixel viewport if a second column opens just across the breakpoint. Inside a reusable card component, a single viewport rule may be unable to distinguish a three-column list from a one-column feature placed on a page of the same viewport width. Write the sizes for the actual placement, or choose a common aspect and acceptable candidate ladder if the card must support many placements. For eligible lazy-loaded images the HTML standard also describes an automatic size mechanism. Confirm support and provide an appropriate fallback for the contexts you serve.
Let candidates express what the files contain
With width descriptors, a candidate labeled 800w is supposed to be an image whose intrinsic width is 800 pixels. Open generated files or inspect their dimensions after the optimizer runs. A mismatched descriptor feeds the browser false information even if the image happens to look acceptable on a particular screen. Also check that each source points to the version it claims. A server route can return a cached copy of a differently sized file, and a list of technically distinct URLs is useless if all of them end up carrying the same original bytes.
The browser compares those candidates with a source size and its display conditions. In a simple case a 400 CSS pixel slot on a device with a device pixel ratio of two suggests about 800 physical pixels across. Its exact selection is allowed to account for factors such as cache state or preferences. It might reuse an already loaded larger candidate after resizing instead of immediately requesting a smaller one. Test new navigations with cache state controlled before assuming the selection algorithm is wrong.
For an icon or avatar with a fixed size in CSS pixels, density descriptors such as 1x and 2x can be an easier match. An avatar displayed at 64 CSS pixels can offer a 64-pixel-wide file at 1x and a 128-pixel-wide file at 2x. When the slot changes size across layouts, use the expected slot width with width-based candidates. Keep each candidate list to one descriptor style so the browser can interpret the alternatives consistently. The HTML standard defines how the browser treats the available sources and fallbacks in each case.
Separate composition from resolution and format
A responsive crop solves a framing problem. Consider a wide landscape photo where a person is positioned on the far left and the subject they are looking at is centered. The page may display it as a narrow portrait lead on a phone. Resizing the desktop crop to a smaller file can keep the pixels crisp but still remove the person or make both elements difficult to see. A deliberately made mobile crop can preserve the story. A picture element lets you give the browser a source selected by a media condition. Each crop can have its own appropriate resource variants.
Format selection solves another problem. Equivalent representations may be encoded as AVIF, WebP, or JPEG with different compression and decoder requirements. A supported format may have a smaller file, but its efficiency depends on the photo and export settings. Browsers choose a source according to supported format and the order of matching source elements. The nested image provides the fallback and carries the alternative text. If you support both crops and formats, examine the order so a broadly permitted format source does not take precedence over the needed narrow crop. HTML Standard on the picture element
Some engineering choices can affect the editorial image. A small heavily compressed export may smooth skin, introduce ringing around text, or damage a pattern of fine branches. Generate size variants from a good master. Look closely at two or three kinds of content you publish before choosing one compression setting across the site. A crop with a single prominent subject can tolerate small sizes more easily than an intricate group photo readers are expected to inspect. The smallest candidate only saves money or time when the served image still does its job.
Reserve the right space before the pixels arrive
A browser can lay out the page with less movement if it knows the size ratio of the image before it is fetched. Provide correct intrinsic dimensions for the fallback image, and make the display rules scale it to the available width. For a consistent landscape card, a wrapper with the selected aspect ratio and deliberate object-fit behavior can also keep artwork aligned. When a mobile source uses a different crop ratio, make sure the reserved area reflects that change. Otherwise a downloaded narrow image may shift nearby text or a covering box may cut off a part of the crop you preserved on purpose.
A lead image above the fold often needs to start loading promptly. Marking every image with lazy loading can postpone that first image in ways that make the article feel slow. Below the initial view, deferred loading can help avoid requesting a large archive of cards a reader never reaches. Verify the policy with actual page behavior. Preloading several variants independently can waste the same requests that responsive selection was meant to reduce. A useful image pipeline prioritizes a small number of early visible resources and allows later ones to wait.
Keep placeholders modest. A ratio-preserving box with the correct background can keep text steady while the final image loads. An oversized preview or blurred original increases bytes for little benefit if it competes with the same hero resource. Check what happens when the image URL returns an error. The intended text should remain readable and the rest of the page should remain navigable. That is easier to test when alt text and semantic markup are part of the same component as the resource list.
Inspect one page at three widths
Open the page at a narrow phone width, close to a layout breakpoint, and at a wide desktop width. Record the visible width of the image, pixel density, selected URL, downloaded bytes, and the crop you actually see. In a browser console or element inspection, the image's currentSrc can identify the selected source. Use a fresh navigation with consistent network and cache settings to compare. The network panel tells you which data transferred, while the page tells you whether the framing and image scale work.
Include one case with the browser zoomed in or with a user's text size increased, if that can change your page's columns. A flexible reading layout can reflow under those conditions and give a card an unexpectedly narrow or wide slot. Check the image after reopening the page at that state. It may be reasonable to serve a neighboring candidate, but a repeated jump to an oversized original deserves a closer look.
For a production change, save the old and new selected URLs and file sizes for one or two reference pages. Run both through the same cold-load scenario. If someone later changes a breakpoint or adds a rail to the article, that record gives them a quick comparison. A small table of tested placements can be more maintainable than a separate image setting documented for every photograph.
When a 300-pixel card repeatedly downloads a much larger resource, look first at the source width hint and the available sizes. When a photo stays blurry at a normal viewing distance, check whether the largest variant covers the rendered size at the target density and whether compression damaged it. When the correct size arrives with the wrong crop, look at the media condition and source ordering. These are distinct faults with distinct fixes. A responsive image is effective when the page geometry, encoded candidates, and visible composition all describe the same placement.




