This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
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 |
This element includes only global attributes.
media
attributeThe 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>
type
attributeThe 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>
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of '<picture>' in that specification. | Living Standard | Initial definition |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 38 | (Yes) | 38 (38) | Edge 13 | 25 | 9.1 |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 38 | (Yes) | 38.0 (38) | No support | 25 | iOS 9.3 |
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture