Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Web HTMLStyleElement API | StyleElement type property

  • Last Updated : 31 Jul, 2019

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.


Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

getType = style.type;

Example: get the type attribute.

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

Click the button:

When the button is clicked:

Supported Browsers:

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!