Skip to content
Related Articles
Open in App
Not now

Related Articles

Web HTMLStyleElement API | StyleElement type property

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

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.


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

Start Your Coding Journey Now!