Open In App

HTML | <a> media Attribute

Last Updated : 12 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

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:

ValueDescription
andAND operator
notNOT operator
,OR operator

Devices: 

ValueDescription
allSuitable for all devices
auralSpeech synthesizers
brailleBraille feedback devices
handheldHandheld devices (small screen, limited bandwidth)
projectionProjectors
printPrint preview mode/printed pages
screenComputer screens
ttyTeletypes and similar media using a fixed-pitch character grid
tvLow resolution or limited scroll ability type devices like Television.


Values: 

ValueDescription
widthTargeted display area’s width.
heightTargeted display area’s height
device-widthTarget display or paper’s width.
device-heightTarget display or paper’s height.
orientationTarget display or paper’s orientation.
aspect-ratioWidth/height ratio of the targeted display area.
device-aspect-ratioDevice-width/device-height ratio of the target display/paper.
colorBits per color of target display.
color-indexNumber of colors the target display can handle.
monochromeBits per pixel in a monochrome frame buffer.
resolutionPixel density (dpi or dpcm) of the target display/paper.
scanScanning method of a tv display.
gridIf the output device is grid or bitmap.

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

Example: 

index.html
<html>

<head>
    <title>
        HTML anchor media Attribute
    </title>
</head>

<body>
    <h1>GeeksForGeeks</h1>
    <h2>
    HTML anchor media Attribute
</h2>
    <a href="https://www.geeksforgeeks.org/community/"
    media="print and (resolution:300dpi)">
        Click to open in the same tab
    </a>
    <br>
    <a href="https://www.geeksforgeeks.org/community/"
    target="_blank"
    media="print and (resolution:300dpi)">
        Click to open in a different tab
    </a>
</body>

</html>

Temporary Note on Output : On Run, The output may show a "Refuse to Connect" error due to security restrictions from the GeeksforGeeks site, which prevents embedding. To see the output, replace the src URL with one that allows iframe embedding, such as "https://www.example.com/".

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

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

Similar Reads