Skip to main content
InterviewHubPRO
Section Overview
Q43

Question 43 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

86%
HTML5 & Web APIs (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Responsive Images: `<picture>` vs `<img>` with `srcset` and `sizes`.

senior LevelCode ExampleDocker & ContainersSystem Design

In Simple Words:

  • srcset + sizes on <img> (Resolution Switching): Delivers identical image content in different pixel densities (1x, 2x, 3x) or widths so mobile devices don't download heavy desktop files.
  • <picture> (Art Direction & Format Fallback): Crops/changes image composition for small screens or serves modern formats (.avif, .webp) with fallback to .jpg.
html
<picture>
  <source media="(min-width: 1024px)" srcset="/hero-wide.avif" type="image/avif">
  <source media="(min-width: 640px)" srcset="/hero-medium.webp" type="image/webp">
  <img src="/hero-mobile.jpg" alt="Interview Hero Banner" loading="lazy" decoding="async">
</picture>