Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTML | <style> media Attribute

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The HTML style media attribute is used to specify the media or device the CSS style is optimized for. this attribute specify the style is for specific devices like print media or speech. This attribute can accept several values. 

Syntax:

<style media="value">

Possible Operators:

ValueDescription
andAND operator
notNOT operator
,OR operator

and aboveDevices:

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>
    <style>
        h1 {
            color: green;
        }
    </style>
    <style media="print">
        h1 {
            color: green;
        }
    </style>
</head>
 
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <p><a href="https://ide.geeksforgeeks.org/tryit.php"
              target="_blank">
          Click here
          </a>
    </center>
</body>
 
</html>

Output:

  

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

  • Google Chrome 1 and above
  • Edge 12 and above
  • Internet Explorer 3 and above
  • Firefox 1 and above
  • Apple Safari 1 and above
  • Opera 3.5 and above

My Personal Notes arrow_drop_up
Last Updated : 27 Jul, 2022
Like Article
Save Article
Similar Reads
Related Tutorials