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

Accessibility Considerations with Picture

Ensure alt text on the img element describes all variants and maintains semantic meaning across crops.

Accessibility Considerations with Picture

What you'll learn: How to write alt text for <picture> elements that accurately describes all visual variants and maintains meaning across different crops and formats.

The Core Challenge

When you use the <picture> element for art direction, you're serving different images to different viewports—perhaps a wide landscape crop on desktop and a tight portrait crop on mobile. The critical accessibility rule: the alt attribute on the <img> inside <picture> must describe what matters across ALL variants.

Think of it like describing a movie scene that's been cropped differently for TV versus cinema. You wouldn't describe just the TV version—you'd describe the essential action or subject that's present in both.

Writing Alt Text for Multiple Crops

The alt text lives on the <img> element (the fallback), not on <source> elements. This means one description must work for all visual variants:

<picture>
  <source media="(min-width: 768px)" srcset="team-wide.jpg">
  <source media="(max-width: 767px)" srcset="team-portrait.jpg">
  <img src="team-wide.jpg" alt="Development team collaborating at a conference table">
</picture>

Good: Describes the core subject (team collaborating) visible in both wide and cropped versions.

Bad: "Five people sitting around a table with laptops and a whiteboard in the background"—the cropped mobile version might not show all five people or the whiteboard.

Focus on the Essentials

Strip your alt text down to what's semantically consistent across all crops. If the mobile crop zooms in on just two faces while the desktop shows the full room, describe what's universal: the people and their activity, not the room details.

Key Takeaway: The alt attribute in a <picture> element must describe the essential meaning shared across all visual variants, ignoring details that might be cropped out in different source images.