Open In App
Related Articles

HTML media attribute

Improve Article
Save Article
Like Article

The HTML media attribute is employed to 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.


Example: HTML <a> media attribute 


        HTML media Attribute
       media="print and (resolution:300dpi)">
        Click to open in the same tab
       target="_blank" media="print and (resolution:300dpi)">
        Click to open in a different tab


Example: HTML <source> media attribute 


<!DOCTYPE html>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0">
        <source media="(min-width: 600px)"
        <source media="(min-width: 400px)"
        <img src=

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

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 10 May, 2023
Like Article
Save Article
Similar Reads
Complete Tutorials