Hacker News new | ask | show | jobs
by superfad 1836 days ago
The only time the sizes attribute is not needed when using srcset is when the rendered size of the image is fixed.

One example would be a logo that is less than 320px wide (so it fits even on mobile). In that case you can add x descriptors to give a higher quality logo on retina screens. e.g.

<img src="logo.jpg" alt="Logo" srcset="logo.jpg, logo-2X.jpg 2x">

Alternatively use an svg :)

But if the image depends on the viewport width then 'srcset' (without x descriptors but with w descriptors) and in combination with 'sizes' is the way to go.