Questions tagged [srcset]

The srcset attributes on the img element can be used, using the x descriptor, to provide multiple images that only vary in their size

390 questions
132
votes
10 answers

Is there a srcset equivalent for css background image

img with srcset attribute looks like a great way of doing responsive images. Is there an equivalent syntax that works in css background-image property? HTML yah CSS .mycontainer…
Martin Algesten
  • 13,052
  • 4
  • 54
  • 77
131
votes
7 answers

Is it possible to see which srcset image a browser is using with browser developer tools

I've been trying to see which srcset image my browser is using via the browsers developer tools, but apart from using the network tab to see which image it fetches i can't tell. Using the network tab would usually be fine, but sometimes I've noticed…
sam
  • 9,486
  • 36
  • 109
  • 160
106
votes
10 answers

responsive images srcset not working

I've been trying to implement the new srcset approach to responsive images, using the following HTML
sygad1
  • 1,392
  • 3
  • 12
  • 19
30
votes
3 answers

Pagespeed-penalty for using srcset

Displaying retina & non-retina to corresponding devices like this: Works. But Google Pagespeed Insight is telling that it cannot render this until…
Raphael Jeger
  • 5,024
  • 13
  • 48
  • 79
26
votes
4 answers

Why is React.js removing the srcset tag on ?

When I have the srcset property on my tag, why doesn't it show up in the browser? It appears as through React.js is stripping it out.
Kevin Ghadyani
  • 6,829
  • 6
  • 44
  • 62
25
votes
5 answers

Object-fit: Cover and Srcset

I am using object-fit: cover on a bunch of images. The frame for the image takes up 50vw and has a dynamic height. The cover attribute works great, but it means that I don't really know how wide my actual image will be at a given time. Most likely…
Andrew Whited
  • 281
  • 3
  • 6
18
votes
3 answers

Responsive img gets wrong images from srcset

Tested using Google Chrome in Incognito mode and reloading the page with "empty cache and hard reload" each time. I have the following html responsive image:
mike-source
  • 1,004
  • 3
  • 17
  • 32
17
votes
1 answer

Google Chrome version 40 srcset attribute problems

I'm seeing a lot of inconsistencies with srcset attribute on img tags (responsive images) in Chrome 40.0.2214.91 Before I updated to Chrome v40 (I was on ~39), srcset attribute worked fine and would swap the image upon browser resize. Now,…
Zeb Pykosz
  • 173
  • 1
  • 1
  • 4
15
votes
1 answer

JPG vs JPEG2000 vs WebP

I'm building my website using React and have multiple images to display. After running an audit using the Google Chrome audit function, I've been getting the "Serve images in next-gen formats" opportunity message. After reading about the various…
Brian Phair
  • 328
  • 4
  • 12
15
votes
2 answers

Get the current image source of a picture element

An HTMLImageElement has a currentSrc property so we can get the current source of an img element. Useful when defining multiple possible sources with srcset. There seems to be no equivalent for an HTMLPictureElement. Is there another way we can find…
Colin Meinke
  • 173
  • 1
  • 1
  • 7
15
votes
1 answer

HTML5 srcset: is 1x mandatory?

When using a responsive image set with without breakpoints (i.e. without the sizes attribute) you typically provide several versions of the same image in different resolution which you then define in the srcset attribute using the…
fritzmg
  • 2,494
  • 3
  • 21
  • 51
14
votes
1 answer

How to use srcset and sizes for responsive images

I have following snap-points: 480px, 900px, 1800px, 2400px. and this markup:
user5671193
14
votes
2 answers

Is it possible to recalculate the `srcset` image used if browser window is resized?

Is it possible to get srcset to recalculate the browser window size once the page has loaded, and thus update the image its using. The reason you'd want to do this is because if on a desktop you have your browser window compressed, load a site,…
sam
  • 9,486
  • 36
  • 109
  • 160
13
votes
2 answers

HTML5 srcset: Mixing x and w syntax

I'm trying to figure out a way to provide high dpi images to iOS8 clients while also providing responsive image resources for browsers supporting the w syntax. According to the W3C standard it should be possible to mix both syntaxes in one srcset…
s2b
  • 133
  • 1
  • 5
13
votes
3 answers

How do I tell srcset attribute to load NO images when viewport smaller than certain size

I'm having trouble understanding how to keep srcset from loading any images on screens < 768px. I've tried the code below but the sizes attribute doesn't seem to do what you may think. Below loads 1024.jpg on all screen sizes:
Ben Racicot
  • 5,332
  • 12
  • 66
  • 130
1
2 3
25 26