Skip to main content

The <picture> Element

As defined in the HTML Living Standard, the <picture> element is a container used to provide multiple versions of an image, allowing the browser to choose the most appropriate one based on screen size, resolution, or format support.

Visual Example (Responsive Art Direction):

A demonstration of the picture element switching images based on viewport width.

(Resize your browser window to see the image change.)

<picture>
  <source media="(min-width: 800px)" srcset="desktop.jpg">
  <source media="(min-width: 400px)" srcset="tablet.jpg">
  <img src="mobile.jpg" alt="Description of the image">
</picture>
View HTML Living Standard: The picture element

Why Use <picture>?

Unlike the standard <img> tag with srcset, the <picture> element allows for Art Direction.

WCAG Principle: Robustness & Perceivability

Success Criterion 1.1.1 (Level A): The <picture> element itself is a wrapper. The actual accessibility (the alt text) must be placed on the nested <img> element. If the image is missing the alt attribute, the entire component becomes inaccessible to screen reader users.

Understand SC 1.1.1: Non-text Content

Performance Impact

By using <picture>, you prevent the browser from downloading unnecessarily large images on small devices, which directly improves Core Web Vitals (LCP) and ensures a better experience for users on limited data plans.