Explore Bato Web Agency Webflow Certified Partner Profile Explore Bato Web Agency Webflow Certified Partner Profile

What is the difference between srcset, sizes and the picture element?

Illustration without a description Illustration without a description

srcset lists candidate image resources, sizes tells the browser the expected rendered slot width, and picture lets authors provide alternative sources for art direction or formats. They solve related but different responsive-image problems.

 

With width descriptors, srcset records each file’s intrinsic width, such as 480w or 960w. Sizes provides media conditions and slot lengths. The browser combines the chosen slot with pixel density and other factors to select a candidate before the CSS layout is complete.

 

<img
src="photo-960.jpg"
srcset="photo-480.jpg 480w, photo-960.jpg 960w, photo-1440.jpg 1440w"
sizes="(max-width: 40rem) 100vw, 50vw"
width="960"
height="640"
alt="Workshop participants reviewing a prototype">

 

Use picture when the crop or composition should change, or when a format source needs a fallback. Each source can have media and type conditions, while the nested img supplies the alt text, intrinsic dimensions and fallback. Picture should not be used merely because multiple resolutions exist.

 

Sizes is a selection hint, not a CSS sizing rule. The stylesheet must still set the displayed width. Keep the sizes conditions synchronized with real layout breakpoints, and inspect currentSrc plus network requests to verify that the browser receives accurate candidates. Add this case to responsive regression tests with long content, browser zoom and at least one narrow embedded container. Record the expected wrapping and focus behavior so later component changes can be checked against a known result. Add this case to responsive regression tests with long content, browser zoom and at least one narrow embedded container. Record the expected wrapping and focus behavior so later component changes can be checked against a known result.