Course contentsShow
← Web Development
Lesson 1225 of 2,98222. Responsive Images and MediaFree lesson

Testing srcset Behavior

Using DevTools to verify which image source the browser selected and why.

Testing srcset Behavior

What you'll learn: How to use browser DevTools to confirm which image source was selected from your srcset and understand the browser's decision-making process.

After writing srcset and sizes attributes, you need to verify the browser is actually loading the images you expect. Browsers make intelligent choices based on viewport width, pixel density, and your sizes hints—but you can't see this just by looking at the page. DevTools reveals what's happening behind the scenes.

Opening the Network Panel

In your browser's DevTools (F12 or right-click → Inspect), navigate to the Network tab. Refresh your page and filter by "Img" to see only image requests. You'll see which specific file the browser downloaded—for example, hero-800w.jpg instead of hero-1200w.jpg.

Checking the Element Inspector

Select the <img> element in the Elements (or Inspector) panel. Look at the computed properties or hover over the src attribute. Modern DevTools often show:

  • The currentSrc property (the actual URL chosen)
  • The reason for selection (viewport width, pixel density)

Testing Different Conditions

Resize your browser window and refresh. Watch the Network panel to see if a different image loads. Use DevTools' device emulation to simulate different screen sizes and pixel ratios (like Retina displays). This helps you verify your breakpoints work correctly.

What to Look For

If the browser always loads the largest image, your sizes attribute might be too generous or missing. If it loads the smallest on a large screen, check your width descriptors match your actual image dimensions.

Key Takeaway: Browser DevTools' Network and Elements panels let you verify which srcset image loaded and test your responsive image strategy across different viewports and pixel densities.