4 ms·
Sizes is needed when you specify the intrinsic width of the image with the w descriptor I believe. Alternatively you can specify resolution factor (1x, 2x, etc)
by Santosh83 5y ago
Sizes is needed when you specify the intrinsic width of the image with the w descriptor I believe. Alternatively you can specify resolution factor (1x, 2x, etc) in which case the sizes attribute is not needed and the choice of which image to download is placed on the browser in a more autonomous manner than specifying sizes.
- chiefalchemist 5y agoYou might be correct. Regardless, the choice is always on the browser, as it should be. It's the only one who knows the screen res, how wide and tall, the markup, etc. With all that it picks. Again, that article I shared does a great job of explaining. I'll re-read to find out about 1x, 2x, etc.
- superfad 5y agoThe 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.