Lesson 42 of 55
HTMLThe `<picture>` Element and Responsive Images
9 min
Course progress76%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 42 of 55
HTML9 min
Keep these ideas in mind as you work through the lesson.
<picture> Element – Art Direction & Responsive Images<picture> lets you serve different images based on media queries, pixel density, or format support.
<picture>
<source media='(min-width: 800px)' srcset='hero-large.webp' type='image/webp' />
<source media='(min-width: 800px)' srcset='hero-large.jpg' type='image/jpeg' />
<source srcset='hero-medium.webp' type='image/webp' />
<img src='hero-medium.jpg' alt='Hero illustration' loading='lazy' />
</picture>
srcset (1x, 2x) for retina displays.<img> inside <picture> for browsers that don’t support the element.<picture> with lazy loading (loading='lazy') for off‑screen images.<source> elements reasonable; too many can increase download size.<picture><img> present with descriptive alt? ✅type attributes used for modern formats (image/webp)? ✅loading='lazy' added for non‑above‑the‑fold images? ✅<picture> support (fallback works)? ✅Tip: Use the Chrome DevTools Network panel to verify that the correct source is selected for the current viewport.