Document: title プロパティ

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.

document.title プロパティは、現在の文書の題名を取得または設定します。 存在する場合、<title> の値が既定値です。

文字列で、この文書の題名が入ります。題名が document.title に設定することで上書きされている場合は、その値が入ります。そうでなければ、 <title> 要素に指定された題名が入ります。

js
document.title = newTitle;

newTitle は文書の新しい題名です。代入すると、 document.title の返値、文書に表示される題名(ウィンドウのタイトルバーやタブなど)、文書の DOM(HTML 文書の <title> 要素の内容など)にも反映されます。

html
<!doctype html>
<html lang="ja">
  <head>
    <meta charset="UTF-8" />
    <title>Hello World!</title>
  </head>
  <body>
    <script>
      alert(document.title); // "Hello World!" と表示
      document.title = "Goodbye World!";
      alert(document.title); // "Goodbye World!" と表示
    </script>
  </body>
</html>

仕様書

Specification
HTML
# document.title

ブラウザーの互換性

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
title

Legend

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

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