Atributo HTML <translation> srcset

❮ Tag HTML <source>

Exemplo

Um elemento <picture> com dois arquivos de origem e uma imagem de fallback:

<picture>
  <source media="(min-width:650px)" srcset="img_pink_flowers.jpg">
  <source media="(min-width:465px)" srcset="img_white_flower.jpg">
  <img src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;">
</picture>

Definição e uso

O srcsetatributo especifica a URL da imagem a ser usada em diferentes situações.

Este atributo é obrigatório quando <source>usado em <picture>.


Suporte ao navegador

Os números na tabela especificam a primeira versão do navegador que suporta totalmente o atributo.

Attribute
srcset 38.0 13.0  38.0 9.1 25.0

Sintaxe

<source srcset="URL">

Valores de atributo

Value Description
URL Specifies the URL of the image.

Possible values:

  • An absolute URL - points to another web site (like href="http://www.example.com/flower.jpg")
  • A relative URL - points to a file within a web site (like href="flower.jpg")

❮ Tag HTML <source>