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

368 questions
106
votes
8 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
  • 11,444
  • 2
  • 46
  • 74
90
votes
5 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
  • 8,194
  • 30
  • 94
  • 152
79
votes
8 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,102
  • 2
  • 10
  • 19
28
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
  • 4,445
  • 12
  • 43
  • 72
25
votes
3 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
  • 5,392
  • 4
  • 33
  • 50
23
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
  • 261
  • 2
  • 6
16
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
  • 163
  • 1
  • 4
14
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
  • 318
  • 4
  • 12
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
  • 8,194
  • 30
  • 94
  • 152
13
votes
2 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
  • 895
  • 2
  • 14
  • 30
12
votes
3 answers

Detect used srcset or picture tag source with JavaScript

When you're using srcset like this: Or using a picture tag like this:
Tyler V.
  • 1,873
  • 16
  • 36
12
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
  • 1,929
  • 2
  • 16
  • 43
11
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
  • 133
  • 1
  • 7
11
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
  • 4,039
  • 8
  • 42
  • 96
10
votes
3 answers

img not responding to srcset specified dimensions

I wanted to implement the responsive images using srcset, as described here, so the image src that the user loads is the most similar to his resolution. The thing is that I made this test and it doesn't respond to viewport changes,
Toni Michel Caubet
  • 17,157
  • 49
  • 178
  • 335
1
2 3
24 25