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 July 2015.

headDocument インターフェイスの読み取り専用のプロパティで、この文書の <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

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
head

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Has more compatibility info.

関連情報