how do I handle IMG srcset and widths together?
Lighthouse is yelling at me to add widths to my images where I use srcset, doesn't this negate srcset and constrain the width to the width attributes value in pixels? How are you supposed to use these together?
7 Replies
maybe something along these lines so that its responsive?
Hmm, can you do widths that way?
i would assume so, theres a 300w and 600w so i believe its possible
Hmm, I'll try it when I'm back at my computer, thanks
np
as I suspected, this fails the w3c html validator:
Error: Bad value 100% for attribute width on element img: Expected a digit but saw % instead.
srcset sizes are based on the screenwidth, not the images itself (just like a media-query)
so you can give it a width on the element. and in css set the cover with the actual needed size