You are here: Reference > JavaScript > client-side > style handling > properties > title (styleSheet)

title property (styleSheet)

Browser support:
Sets or returns the title of the current styleSheet.
In Firefox, Opera, Google Chrome and Safari, the title property is read-only. If a stylesheet belongs to a style or imported by a link element, then the title property can be used to set or retrieve the title.

Syntax:

object.title;
You can find the related objects in the Supported by objects section below.
This property is read/write.

Possible values:

String that sets or retrieves the title.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the title property:
<head>
    <style id="myStyle" title="This is an empty style sheet">
    </style>

    <script type="text/javascript">
        function GetTitle () {
            var styleTag = document.getElementById ("myStyle");

                // the style sheet in the style tag
            var sheet = styleTag.sheet ? styleTag.sheet : styleTag.styleSheet;

            alert (sheet.title);
        }
    </script> 
</head>
<body>
    <button onclick="GetTitle ()">Get the title of the stylesheet!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content