HTMLTitleElement: text property

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.

The text property of the HTMLTitleElement interface represents the text of the document's title. Only the text part is included; tags within the element and their content are stripped and ignored.

Value

A string.

Examples

Consider the example below:

html
<!doctype html>
<html lang="en-US">
  <head>
    <title>
      Hello world! <span class="highlight">Isn't this wonderful</span> really?
    </title>
  </head>
  <body></body>
</html>
js
const title = document.querySelector("title");
console.log(title.text); // yield: "Hello world!  really?"

As you can see, the tag span and its content were skipped.

Specifications

Specification
HTML Standard
# dom-title-text-dev

Browser compatibility

BCD tables only load in the browser