<img src="hero-960.jpg" srcset="hero-480.jpg 480w, hero-960.jpg 960w, hero-1440.jpg 1440w" sizes="(max-width: 640px) 100vw, 50vw" alt="Echipă la lucru">On narrow screens the image occupies the viewport, while in the wide layout it uses about half.
LESSON 78 OF 100
Offer three real widths and tell the browser how much space the image will occupy.
The w descriptors state each candidate’s intrinsic width. When they are used, sizes describes the display size so the browser can choose a resource before downloading it.
<img src="hero-960.jpg" srcset="hero-480.jpg 480w, hero-960.jpg 960w, hero-1440.jpg 1440w" sizes="(max-width: 640px) 100vw, 50vw" alt="Echipă la lucru">On narrow screens the image occupies the viewport, while in the wide layout it uses about half.
<img srcset="hero-480.jpg 480w, hero-960.jpg 960w" alt="Echipă">With w descriptors, omitting sizes makes the browser assume 100vw, which can select a resource larger than needed.
Add three candidates at 480w, 960w and 1440w and a sizes value with a maximum 640px condition plus the final 50vw value.
Unique descriptors describe the files, while the sizes list describes expected space in two layout situations.
ANALYSIS REQUEST
The initial discussion is without obligation. You receive an honest recommendation, suitable stages and the factors that affect price.