MDN’s new design is in Beta! A sneak peek: https://blog.mozilla.org/opendesign/mdns-new-design-beta/

<picture>

Houve um erro de script nesta página. Enquanto este erro é encaminhado para os editores do site, você pode ver o conteúdo parcial abaixo.

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

{{HTMLRef}}{{SeeCompatTable}}

The HTML <picture> element is a container used to specify multiple {{HTMLElement("source")}} elements for a specific {{HTMLElement("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 {{HTMLElement("source")}} elements, followed by one {{HTMLElement("img")}} element, optionally intermixed with script-supporting elements.
Tag omission {{no_tag_omission}}
Permitted parents Any element that allows embedded content.
Permitted ARIA roles None
DOM interface {{domxref("HTMLPictureElement")}}

Atributos

This element includes only global attributes.

Exemplo 1: Uso com atributo media 

The media attribute lets you specify a media query that the user agent will evaluate to select a {{HTMLElement("source")}} element. If the media query evaluates to false, the {{HTMLElement("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 {{HTMLElement("source")}} element's srcset attribute. If the user agent does not support the given type, the {{HTMLElement("source")}} element is skipped.

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

Specificações

Specification Status Comment
{{SpecName('HTML WHATWG', 'embedded-content.html#the-picture-element', '<picture>')}} {{Spec2('HTML WHATWG')}} Initial definition

Compatibilidade entre navegadores

{{Tablela de compatibilidade}}

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 38 {{CompatVersionUnknown}} {{CompatGeckoDesktop("38")}} Edge 13 25 9.1
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 38 {{CompatVersionUnknown}} {{CompatGeckoMobile("38")}} {{CompatNo}} 25 iOS 9.3

See also

  • {{HTMLElement("img")}} element
  • {{HTMLElement("source")}} element

Etiquetas do documento e colaboradores

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