-
Notifications
You must be signed in to change notification settings - Fork 22.5k
/
index.md
51 lines (34 loc) · 996 Bytes
/
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
---
title: "Document: head property"
short-title: head
slug: Web/API/Document/head
page-type: web-api-instance-property
browser-compat: api.Document.head
---
{{APIRef("DOM")}}
The **`head`** read-only property of
the {{domxref("Document")}} interface returns the {{HTMLElement("head")}} element of
the current document.
## Value
An {{domxref("HTMLHeadElement")}}.
## Examples
```html
<!doctype html>
<head id="my-document-head">
<title>Example: using document.head</title>
</head>
<script>
const theHead = document.head;
console.log(theHead.id); // "my-document-head";
console.log(theHead === document.querySelector("head")); // true
</script>
```
## Notes
`document.head` is read-only. Trying to assign a value to this property will
fail silently or, in [Strict Mode](/en-US/docs/Web/JavaScript/Reference/Strict_mode), throws a {{jsxref("TypeError")}} .
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("document.body")}}