Use HTML’s picture element when your mobile banner needs a tighter crop than your desktop banner. The live example below shows a wide group of watermelon wedges above 600 CSS pixels and a portrait crop focused on the red flesh and green rind at 600 pixels or below.
Prepare two crops from the same image
Start with the Frame-Filling Watermelon Wedges image, an AI-generated 1536 × 1024 WebP available under the Stock Tour Asset License. The 1200 × 675 desktop crop retains wedges across the frame. The 600 × 750 mobile crop uses a region farther right, where a large wedge keeps its seeds and rind visible in a narrow window. Export and name the two crops separately.
Set the mobile source and keep a desktop fallback
Put the mobile crop in a source with a media condition. Put the desktop crop in the final img element. That element supplies the fallback and the text alternative for both crops. The width and height describe each crop’s ratio, and the image styles let it fit the available width without stretching. The MDN responsive images guide shows how browsers choose the first matching source.
<picture>
<source media="(max-width: 600px)"
srcset="watermelon-banner-mobile.jpg"
width="600" height="750">
<img src="watermelon-banner-desktop.jpg"
width="1200" height="675"
alt="Overlapping red watermelon wedges with black seeds and green rind"
style="display:block;width:100%;height:auto">
</picture>
Check which image the browser loaded
Open the page once above and once below 600 CSS pixels. In browser DevTools, select the nested img under picture and check its currentSrc property. On this page, the selected filename ends in watermelon-banner-desktop.jpg at desktop widths and watermelon-banner-mobile.jpg at phone widths. The src attribute still shows the desktop fallback in either case.
If the same image composition works at every width and only the position needs a small adjustment, shift the crop with CSS object-position. Use two files when you want to decide exactly which part of the image appears at each size.



