Open In App

HTML | <source> srcset Attribute

Last Updated : 19 Jul, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The HTML srcset attribute is used to specifies the URL of an image to use in different situations. when <source> is used in <picture> it is required
Syntax: 
 

<source srcset="URL">

Attribute Values 
 

  • URL: It specifies the URL of image

Example: 
 

html




<!DOCTYPE html>
 
<html>
 
<head>
 
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0">
 
</head>
 
<body>
 
    <picture>
 
        <source media="(min-width: 600px)"
                srcset=
 
        <source media="(min-width: 400px)"
                srcset=
 
        <img src=
             style="width:auto;">
 
    </picture>
 
</body>
 
</html>


Output: change the size of browser 
 

 

 

Supported Browsers:The browsers supported by HTML srcset Attribute are listed below 
 

  • Google Chrome 38
  • Firefox 38
  • Apple Safari 9
  • Opera 25
  • Edge 18

 


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads