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

href property (CSSImportRule, styleSheet)

Browser support:
Sets or returns the URL of a linked style sheet.
This property can be used for stylesheets that belong to link elements. If the stylesheet belongs to a style element, the href property is an empty string (Internet Explorer before version 9) or null (in other browsers).


You can find the related objects in the Supported by objects section below.
The href property is read-only in Firefox, Opera, Google Chrome and Safari, and it is read/write in Internet Explorer.

Possible values:

String that specifies or retrieves the URL. It can be an absolute or relative path as well. Relative paths are relative to the base URL. The base URL is the location of the current document, but it can be overridden by the base tag.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the href property:
    <link rel="stylesheet" type="text/css" href="style.css" />
    <script type="text/javascript">
        function GetHref () {
            alert ("The URL of the first stylesheet:\n" + document.styleSheets[0].href);
    <button onclick="GetHref ();">Get linked object location!</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content