Skip to content
SIMON WARDMUSIC · TECHNOLOGY · CREATION
THE JOURNAL / SIMON WARD

How to Show a Different Image Crop on Mobile with HTML Picture

19 November 2026 · Simon Ward · 9 min read
A hiker in a yellow raincoat stands on a rocky ridge.

If you want a wide banner on desktop and a close-up on phones, use the HTML picture element. It lets the browser choose a different crop before it downloads the image. You can keep the extra space around your subject on a wide screen and bring the subject closer on a narrow one, using the same image description for both versions.

This guide builds a simple example with a hiker in the centre of a landscape. The wide version shows the hills around the hiker. The phone version keeps the hiker large enough to see without asking a reader to zoom in. The same method works for a product photo, a portrait or any banner where the framing needs to change on a smaller screen.

1. Decide where the crop should switch

Open your page at a narrow width and look at the actual image slot. If the photo is in a card, resize the page until you see when the cards stack into one column. If it sits at the top of an article, check when the image stops sharing the row with the text. Start with the point where the layout changes and adjust it if the composition starts to break earlier.

This example switches at 700 pixels because the landscape works well above that width. Treat that as an example rather than a device classification. A tablet in a split-screen window or a desktop browser resized to 650 pixels will also use the narrow composition. That is usually what you want because the layout has the same room to work with.

If the whole scene still makes sense at every width and you only want to reduce the download size, use srcset and sizes on a regular image. Different sizes of the same composition are a resolution choice. This guide uses picture because the phone crop deliberately removes the scenery at the sides. The HTML standard's image examples cover both cases.

2. Export two crops from the same original

Keep the uncropped source file somewhere outside your deployment folder. Export a wide copy first and check that the subject remains visible against the background. For the example below, save it as ridge-wide.WebP at 1,200 by 600 pixels. Then return to the original and make a narrower crop around the hiker. Save it as ridge-close.webp at 600 by 750 pixels.

The wide crop shows the surrounding hills, while the tighter crop centres on the hiker in a yellow raincoat.
Example crops from the same photograph. Desktop on the left, mobile on the right.

Always check both crops at their intended display size. A crop that looks clear while you are editing it at full scale may lose a small object once it appears in a phone-sized column. Check the edges as well. A crop can accidentally cut through a hand, remove a sign that provides context or leave the subject too close to the top. Leave a little breathing room if your design later adds rounded corners.

Put the two files beside your HTML page while testing. That makes the paths easy to check. Once it works, move them to an images folder if your project already uses one, and change both paths in the markup. Match the file names exactly, including capital letters, because a path that resolves on your computer can still fail after deployment to a case-sensitive host.

3. Add the picture element

Place the following markup inside the body of your HTML file. Keep the source before the img. The browser checks the sources in order and uses the image as the fallback when no source applies.

<picture>
  <source
    media="(max-width: 700px)"
    srcset="ridge-close.webp"
    width="600"
    height="750">
  <img
    src="ridge-wide.webp"
    width="1200"
    height="600"
    alt="A hiker in a yellow raincoat stands on a rocky ridge.">
</picture>

There is one image element, even though the browser has two files to choose from. The alt text belongs on that image element and must make sense for either crop. Here it describes the hiker and ridge, which appear in both files. If the wide view contains information that disappears from the phone crop, add that information in nearby text or reconsider what you cut.

The width and height values describe the proportions of the actual files. They also give modern browsers information they can use to reserve the right space before the download finishes. Enter the real values from your export. If you reuse this example with a square phone image, replace the dimensions on the source with the dimensions of your square file.

A matching media query can still point at a missing file. Check the narrow URL directly if you get a broken image. Keep the desktop file as a sensible fallback, but repair the missing source path rather than assuming the browser will ignore the broken entry. See the picture element reference for the attributes and browser behaviour.

4. Let CSS size the image without cutting it again

Give the surrounding element a class such as article-hero and use the following CSS. It makes the image fill the available width while preserving the proportions of the selected crop. The exact displayed width comes from the container.

.article-hero img {
  display: block;
  width: 100%;
  height: auto;
}

Open the page on desktop and check that the container has a sensible maximum width for the source. An image exported at 1,200 pixels will start to look soft if the design stretches it much beyond that on a high-density display. For an edge-to-edge banner, use a bigger wide file or offer several resolutions. For an article column, its existing width limit may be enough.

Check your current CSS before adding another rule. A theme might already apply a fixed height or set object-fit: cover on the image. That can crop the phone version a second time. If you want the narrow and wide images to display as exported, remove the fixed height for this component or override it in its own stylesheet. If the design requires a container with a forced ratio, plan both exports against that ratio and check which part CSS will remove.

Make sure the document's head has a meta viewport tag with width=device-width, initial-scale=1. A phone browser that lays the page out against a wider virtual viewport may use the desktop source even though the physical screen is narrow. Inspect the existing head before adding the tag so the page ends up with one viewport declaration.

5. Verify the file at each width in Chrome

In Chrome, open DevTools, enable the device toolbar and choose a responsive viewport. Start at 390 pixels wide. Open Network, tick Disable cache and reload with DevTools still open. Filter to images and look for ridge-close.webp. Inspect the image and check that the hiker remains prominent in the rendered crop.

Run the same check at 1,000 pixels. Reload at the new width and look for ridge-wide.webp. Then try 700 and 701 pixels. That last pair confirms which side of the boundary each image is on and can expose a mismatch between the source and your CSS layout. Use the same breakpoint in both places if the crop and layout need to switch together.

If both images appear somewhere in the request list, start with a clean reload at each width. Changing the viewport on a page that has already loaded can legitimately request the other source. If a fresh load at one width still requests both, look for a separate desktop image in the markup, a fixed preload in the head or a CSS background pointing to one of the same files. Use the Network request initiator to figure out what triggered the extra download.

If an image optimiser changes the extension or filename, inspect the response type and the selected URL rather than relying on the suffix alone. On WordPress, the exact file your reader receives can differ from the original upload. This guide to checking which featured image WordPress loads on mobile walks through the Network and Console checks in more detail.

6. Add more resolutions when the demo works

One file per crop is a good place to start because it makes the source switch obvious. If your smaller crop still weighs too much, export more than one resolution of that same crop. For example, make 400 and 800 pixel versions of the narrow image with the same proportions. List them in the mobile source's srcset using 400w and 800w descriptors.

When using width descriptors, set sizes to describe the expected display width of the image. If the image fills the phone viewport except for 16 pixels of padding on each side, calc(100vw - 32px) is a reasonable description of that slot. If the image is in a column, measure the column and express that layout instead. The descriptors belong to the exported file widths. The sizes value belongs to the layout.

You can do the same on the fallback img for the wide crop. For example, offer 800 and 1,600 pixel versions to suit different displays. Keep the height and width attributes in the same proportions as the wide crop. Test the smallest and largest viewports you support, and check a high-density emulation preset before deciding that a larger file means something is wrong. A 400 CSS pixel slot on a device with a pixel ratio of two can make an 800 pixel candidate a reasonable choice.

For a hero at the top of the page, check whether it is the Largest Contentful Paint element in your performance report before changing its loading priority. Lazy loading is often appropriate for a comparison further down an article. Applying it automatically to a prominent first-screen image can delay the most visible part of the page. Measure a fresh navigation and compare the timing after your change.

7. Keep the example easy to maintain

Give both files names that share a common stem, and use the suffixes to identify the crop. When a colleague replaces one file, those names make it easier to find and update its counterpart. Keep the fallback dimensions next to the wide filename and the narrow dimensions next to the narrow one. That makes a future change easier to review without opening the images first.

If the same banner also appears as a card or a social preview, check what that template uses before replacing the image globally. Those surfaces may have different aspect ratios and use different metadata. You can keep the card as it is while changing only the article banner, and test each surface on its own terms.

What to check before shipping

Make sure the narrow and wide files both return successfully, the intended crop appears on each side of the breakpoint and the surrounding content does not jump when the image loads. Check that the one description still matches both views. Compare transfer sizes in the Network panel, since a tight crop can actually weigh more than a wide one if it has more visible detail or was exported at a higher quality setting.

Repeat the test after deployment. Your host may apply caching, your CDN may convert the files, and your content management system may rewrite the markup. The post-deployment check tells you what actually reached the reader. Save the source crops and record the breakpoint with the component so the next person to replace the photo can maintain the same behaviour. You can find more practical HTML and WordPress walkthroughs in the Guides archive.

Share this post