Document: head プロパティ
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2018年6月.
head
は Document
インターフェイスの読み取り専用のプロパティで、この文書の <head>
要素を返します。
値
HTMLHeadElement
です。
例
html
<!doctype html>
<head id="my-document-head">
<title>例: document.head の使用</title>
</head>
<script>
const theHead = document.head;
console.log(theHead.id); // "my-document-head";
console.log(theHead === document.querySelector("head")); // true
</script>
メモ
document.head
は読み取り専用です。このプロパティに値を代入した場合は、暗黙に失敗するか、 厳格モードの場合は、TypeError
が発生します。
仕様書
Specification |
---|
HTML> # dom-document-head-dev> |
ブラウザーの互換性
Loading…