MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

Esta tradução está incompleta. Por favor, ajude a traduzir este artigo.

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

Atributos

This element includes only global attributes.

Exemplo 1: Uso com atributo media 

A 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>

Exemplo 2: Uso com atributo type

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>

Especificações

Specification Status Comment
HTML Living Standard
The definition of '<picture>' in that specification.
Padrão em tempo real Initial definition

Compatibilidade entre navegadores

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) Não suportado 25 iOS 9.3

Veja mais

Etiquetas do documento e colaboradores

 Colaboradores desta página: FLR, jtec-info
 Última atualização por: FLR,