HTML | <picture> Tag

The <picture> tag in HTML is used to gives flexibility to the web-developers to specify image resources. The <picture> tag contains <source> and <img> tags. The attribute value is set to load more appropriate image.
The <img> element is used for the last child element of the picture declaration block. The <img> element is used to provide backward compatibility for browsers that do not support the element, or if none of the source tags matched.

Syntax:

<picture>
    Image and source tag
<picture>

Below example illustrates the <picture> tag in HTML:

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">
          
    <title>
        HTML picture Tag
    </title>
      
    <style>
        body {
            text-align:center;
        }
        h1 {
            color:green;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
      
    <h2>HTML <picture> Tag</h2>
      
    <picture>
        <source media="(min-width: 700px)" srcset=
          
        <source media="(min-width: 450px)" srcset
          
        <img src=
            alt="GFG" style="width:auto;">
    </picture>
</body>
  
</html>

chevron_right


Output:

Supported Browsers: The browsers supported by HTML <picture> tag are listed below:

  • Google Chrome 38.0
  • Internet Explorer 13.0
  • Firefox 38.0
  • Safari 9.1
  • Opera 25.0

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.