Skip to content
Related Articles
Open in App
Not now

Related Articles

Web StyleElement API | StyleElement media property

Improve Article
Save Article
  • Last Updated : 31 Jul, 2019
Improve Article
Save Article

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
Related Articles

Start Your Coding Journey Now!