You are here: Reference > JavaScript > client-side > HTML DOM > properties > type (style)

type property (style)

Browser support:
Specifies or returns the type of style sheet language.
If the value of this property is set, it overrides the default styleSheet language.

Syntax:

object.type;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: type

Possible values:

String that sets or retrieves the language type.
One of the following values:
text/css
Language : Cascading Style Sheets.
text/javascript
Language : JavaScript.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the type attribute:
<head>
    <style type="text/css">
        H1 {border: 2px solid red;}
    </style>
</head>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the type property:
<head>
    <style id="baseStyle" type="text/css">
        H1 {border: 2px solid red;}
    </style>
    <script type="text/javascript">
        function GetStyleType () {
            var style = document.getElementById ("baseStyle");
            alert ("The type of the first style element: " + style.type);
        }
    </script>
</head>
<body>
    <button onclick="GetStyleType ();">Get the type of the style!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content