HTML | <source> srcset Attribute

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output: change the size of browser



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

  • Google Chrome 4.0
  • Firefox 4.0
  • Apple Safari 4.0
  • Opera 10.5
  • Edge

full-stack-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.