Open In App

HTML | <a> media Attribute

Last Updated : 09 Jun, 2021
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The HTML <a> media attribute specifies the media or device the linked document is optimized for. This attribute specifies that the target URL is designed for devices like iPhone, speech or print media. This attribute can accept several values. This can be used only if the href attribute is present.
Possible Operators: 
 

Value Description
and AND operator
not NOT operator
, OR operator

Devices: 
 

Value Description
all Suitable for all devices
aural Speech synthesizers
braille Braille feedback devices
handheld Handheld devices (small screen, limited bandwidth)
projection Projectors
print Print preview mode/printed pages
screen Computer screens
tty Teletypes and similar media using a fixed-pitch character grid
tv Low resolution or limited scroll ability type devices like Television.

Values: 
 

Value Description
width Targeted display area’s width.
height Targeted display area’s height
device-width Target display or paper’s width.
device-height Target display or paper’s height.
orientation Target display or paper’s orientation.
aspect-ratio Width/height ratio of the targeted display area.
device-aspect-ratio Device-width/device-height ratio of the target display/paper.
color Bits per color of target display.
color-index Number of colors the target display can handle.
monochrome Bits per pixel in a monochrome frame buffer.
resolution Pixel density (dpi or dpcm) of the target display/paper.
scan Scanning method of a tv display.
grid If the output device is grid or bitmap.

Note: Prefixes like “min-“ and “max-“ can be used.
Example: 

HTML




                        <html>
 
<head>
    <title>
        HTML anchor media Attribute
    </title>
</head>
 
<body>
    <h1>GeeksForGeeks</h1>
    <h2>
    HTML anchor media 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>


 

\

Output: 

 

Supported Browsers: The browsers supported by HTML <a> media Attribute are listed below: 
 

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

 



Next Article

Similar Reads

three90RightbarBannerImg
  翻译: