Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML | <link> media Attribute

Improve Article
Save Article
Like Article
  • Difficulty Level : Easy
  • Last Updated : 06 Jun, 2022
Improve Article
Save Article
Like Article

The HTML link media attribute is used to specify what media/device the target resource is optimized for. This attribute used to specify a different style for different media type. 

The media attribute can accept several values. 

Syntax:

<link media="value">

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: 

html




<!DOCTYPE html>
<html>
 
<head>
    <link rel="stylesheet"
          type="text/css"
          href="index_screen.css">
 
    <link rel="stylesheet"
          type="text/css"
          href="index_print.css"
          media="print">
</head>
 
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <p><a href="index.html" target="_blank">
      Click here
      </a>
    </center>
</body>
 
</html>

Output:

  

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

  • Google Chrome 1 and above
  • Edge 12 and above
  • Internet Explorer 6 and above
  • Firefox 1 and above
  • Apple Safari 4 and above
  • Opera 12.1 and above

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!