HTML | media attribute

The HTML media attribute is employed specify the media or device the coupled document is optimized for. This attribute specifies that the target URL is designed for special devices like iPhone, speech or print media.
This attribute can accept several values.

Applicable:

Example: HTML <a> media attribute



filter_none

edit
close

play_arrow

link
brightness_4
code

<html>
   
<head>
    <title>
        HTML <a> href Attribute
    </title>
</head>
   
<body>
    <h1>GeeksForGeeks</h1>
    <h2
    HTML <a> href Attribute 
</h2>
       media="print and (resolution:300dpi)"
        Click to open in the same tab 
    </a>
    <br>
       target="_blank"
       media="print and (resolution:300dpi)"
        Click to open in a different tab 
    </a>
</body>
   
</html>

chevron_right


Output:

Example: HTML <source> media attribute

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 browser size.


Supported Browsers: The browsers supported by HTML media attribute are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera


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.