Web HTMLStyleElement API | StyleElement type property

In Web API there are style elements which have a type attribute. To fetch this type attribute we use HTMLStyleElement.type property, which returns the type of the current style.

Syntax:

getType = style.type;

Example: get the type attribute.



filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:
Click the button:

When the button is clicked:

Supported Browsers:

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


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.