Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

Web StyleElement API | StyleElement media property

  • Last Updated : 31 Jul, 2019
Geek Week

In Web API there are style elements which have media attribute. To fetch this media attribute we use property, which specifies the intended destination medium for style information.


label = = label

label is a string which describes a single medium or a comma-separated list.

Example: get the media attribute

<!DOCTYPE html>
      StyleElement media property
        a:focus {
            background-color: magenta;
    <link id="Link" 
          media="screen" />
    <script type="text/javascript">
        function getmedia() {
            var label = document.getElementById('Link');
              'media').innerHTML =;
        <h1 style="color:green;">  
        <h2>HTML StyleElement media property</h2>
        <button onclick="getmedia();"
                id="btn">Get media</button>
        <p id='media'></p>

Click the button:

When the button is clicked:

Supported Browsers:

  • Google Chrome
  • Edge 12
  • Internet Explorer
  • Firefox
  • Safari
  • Opera

My Personal Notes arrow_drop_up
Recommended Articles
Page :