-
Notifications
You must be signed in to change notification settings - Fork 22.5k
/
index.md
58 lines (43 loc) · 1.13 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
title: "StyleSheet: href property"
short-title: href
slug: Web/API/StyleSheet/href
page-type: web-api-instance-property
browser-compat: api.StyleSheet.href
---
{{APIRef("CSSOM")}}
The **`href`** property of the {{domxref("StyleSheet")}}
interface returns the location of the style sheet.
This property is read-only.
## Value
A string containing the stylesheet's URI.
## Examples
On a local Windows machine:
```html
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>href example</title>
<link rel="styleSheet" href="example.css" />
<script>
function sref() {
alert(document.styleSheets[0].href);
}
</script>
</head>
<body>
<div class="thunder">Thunder</div>
<button onclick="sref()">ss</button>
</body>
</html>
```
Returns "file:////C:/Windows/Desktop/example.css"
## Notes
If the style sheet is a linked style sheet, the value of its attribute is its location.
For inline style sheets, the value of this attribute is `null`.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}