Fallback Images and Browser Support
You'll learn how to ensure all users see your images by providing a fallback inside the <picture> element for browsers that don't support responsive images.
The Safety Net for Responsive Images
While modern browsers widely support the <picture> element and srcset, older browsers (like Internet Explorer 11 or very old mobile browsers) don't recognize these features. Without a fallback, users on these browsers would see nothing—just broken images or empty space.
The solution is simple: always include a standard <img> element inside <picture>. Browsers that understand <picture> will use the source selection logic you've defined. Browsers that don't will ignore <picture> entirely and fall back to the <img> tag's src attribute.
Think of it like a restaurant menu with translations. The <picture> element offers specialized options (WebP, AVIF, different sizes), but the <img> inside is the universal fallback—the basic dish everyone can order, no matter what.
How It Works
<picture>
<source srcset="hero.avif" type="image/avif">
<source srcset="hero.webp" type="image/webp">
<!-- Fallback for all browsers -->
<img src="hero.jpg" alt="Scenic mountain view" width="800" height="600">
</picture>
The <img> element does double duty:
- Modern browsers: Use it for sizing, alt text, and accessibility, but load images from
<source>elements - Older browsers: Load the
srcdirectly, ignoring everything else
The src should point to a widely-supported format (JPEG or PNG) that works everywhere.
Key Takeaway: Always nest an <img> with a src attribute inside every <picture> element—it ensures universal browser support and graceful degradation for users on older platforms.