HTML srcset Attribute

HTML srcset Attribute: This attribute defines the URL of the image to use in different situations.

HTML srcset Attribute

This attribute is used when <source> is used in <picture>.

Browser Support

This attribute is supported by the following browsers:

  • Chrome-38.0
  • Firefox-38.0
  • Internet Explorer
  • Safari-9.1
  • Opera-25.0

Example: for srcset Attribute

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<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>
</body>
</html>

HTML srcset attribute