HTML & CSS · Middle · Question 22 of 75
When do you need <picture> rather than just <img srcset>?
- ✓Correct answer: When you need to switch formats (AVIF/WebP with a fallback) or cropping
- 2Always:
<img>alone doesn't support responsiveness orsrcset - 3Only for SVG images, which have no raster dimensions
Explanation
<picture> with multiple <source> elements enables art direction (different cropping on mobile via media) and format selection (type="image/avif"), while the inner <img> is the fallback and carries alt. For a simple resolution switch, srcset/sizes on <img> is enough.