The picture element and the srcset attribute are frequently treated as alternatives, with picture assumed to be the more capable of the two. They solve different problems, and choosing between them is straightforward once you know which problem you have.
Two different questions
Resolution switching asks which size of the same image should be downloaded. The picture is identical in every case, only the file dimensions differ. This is what srcset and sizes are for, and the browser makes the decision.
Art direction asks which image should be shown at all. A wide landscape crop works on a desktop and becomes an unreadable strip on a phone, where a tighter crop centred on the subject is genuinely a different photograph. This is what picture is for, and you make the decision.
The practical test is whether the images differ in anything other than size. If they do not, use srcset and stop.
Art direction with media conditions
Each source carries a media condition, and the browser uses the first whose condition matches.
<picture> <source media="(max-width: 600px)" srcset="/img/hero-square.jpg"> <source media="(max-width: 1000px)" srcset="/img/hero-wide.jpg"> <img src="/img/hero-full.jpg" alt="A workshop bench with tools laid out" width="1600" height="700"> </picture> Order matters absolutely. The browser stops at the first match and does not evaluate the rest, so conditions must run from narrowest to widest when using maximum width, or the broadest one will catch everything.
The image element is not optional
The image element at the end is required and does more than provide a fallback. It carries the alt text, it supplies the width and height attributes, and it is the element that is actually rendered and styled. The source elements are instructions rather than things in their own right.
This means CSS targeting the source elements does nothing. Style the image element, and it will display whichever file was selected.
Serving modern formats
The second common use is format negotiation, using the type attribute rather than a media condition.
<picture> <source srcset="/img/photo.avif" type="image/avif"> <source srcset="/img/photo.webp" type="image/webp"> <img src="/img/photo.jpg" alt="A harbour at dusk" width="1200" height="675"> </picture> The browser takes the first type it can decode, so the most efficient format goes first and the most compatible last. This is a safe way to adopt a newer format without waiting for complete support, since anything that cannot handle it simply moves down the list.
Combining both approaches
A source element can carry its own srcset with width descriptors and its own sizes attribute, which lets each art directed crop also offer several resolutions.
This is powerful and produces markup that is long and easy to get wrong by hand. It is a reasonable thing for a template or component to generate and an unreasonable thing to maintain manually across a large site.
One alt text for all cases
Because the alt attribute lives on the image element, every source shares it. This is a limitation when crops differ substantially, since a tight portrait crop and a wide scene arguably need different descriptions.
The practical answer is to write alt text describing what the image is doing on the page rather than cataloguing what is visible in a particular crop. That description usually holds across all versions, which is a reasonable indication that the alt text was focused on purpose rather than on contents.
Preloading a picture
For a hero image that appears immediately, waiting for the parser to reach it costs visible time. A preload hint in the head starts the download earlier, and it accepts the same image set and media attributes so the correct candidate is fetched rather than all of them.
Use this sparingly. Preloading competes for bandwidth with everything else the page needs, so promoting several images tends to make the page slower overall rather than faster. One image, chosen because it is the largest thing visible on load, is the usual limit.
Lazy loading and picture
The loading attribute belongs on the image element rather than on any source, since the image element is the one being rendered. Applying it to an image inside a picture works exactly as it does elsewhere, and the same caution applies: an image visible without scrolling should not be lazy loaded, because deferring it delays the thing the visitor came to see.
Watch the maintenance cost
Every additional source is another file to generate, store and keep in step with the others. Art direction is worth it for a small number of prominent images, typically a hero or a key illustration, and rarely worth it for every thumbnail in a listing.
A reasonable default is srcset alone for ordinary content images, picture with type sources where you want a modern format, and full art direction reserved for the handful of images where the crop genuinely changes what the visitor sees.