This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The HTML <picture> element is a container used to specify multiple <source> elements for a specific <img> contained in it. The browser will choose the most suitable source according to the current layout of the page (the constraints of the box the image will appear in) and the device it will be displayed on (e.g. a normal or hiDPI device.)

Content categories Flow content, phrasing content, embedded content
Permitted content Zero or more <source> elements, followed by one <img> element, optionally intermixed with script-supporting elements.
Tag omission None, both the starting and ending tag are mandatory.
Permitted parents Any element that allows embedded content.
Permitted ARIA roles None
DOM interface HTMLPictureElement

Attributes

This element includes only global attributes.

Example 1: Using the media attribute

The media attribute lets you specify a media query that the user agent will evaluate to select a <source> element. If the media query evaluates to false, the <source> element is skipped.

<picture>
 <source srcset="mdn-logo-wide.png" media="(min-width: 600px)">
 <img src="mdn-logo-narrow.png" alt="MDN">
</picture>

Example 2: Using the type attribute

The type attribute lets you specify a MIME type for the resource(s) given in the <source> element's srcset attribute. If the user agent does not support the given type, the <source> element is skipped.

​<picture>
 <source srcset="mdn-logo.svg" type="image/svg+xml">
 <img src="mdn-logo.png" alt="MDN">
</picture>

Specifications

Specification Status Comment
HTML Living Standard
The definition of '<picture>' in that specification.
Living Standard Initial definition

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support3813

38

32 — 521

No259.1
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidIE mobileOpera AndroidiOS Safari
Basic support3838 Yes

38

32 — 521

No259.3

1. From version 32 until version 52 (exclusive): this feature is behind the dom.image.picture.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

See also

Document Tags and Contributors

 Last updated by: teoli,