HTMLTitleElement: text property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("HTML DOM")}}
The **text** property of the {{domxref("HTMLTitleElement")}} interface represents the child text content of the document's title as a string. It contains the {{HTMLelement("title")}} element's content as text; if HTML tags are included within the <title> element, they are included as part of the string value rather than being parsed as HTML.
Setting a value for the text property replaces the entire text contents of the <title>.
Value
A string.
Examples
Consider the example below:
<!doctype html>
<html lang="en-US">
<head>
<title>
Hello world! <span class="highlight">Isn't this wonderful</span> really?
</title>
</head>
<body></body>
</html>const title = document.querySelector("title");
console.log(title.text); // "Hello world! <span class="highlight">Isn't this wonderful</span> really?"
title.text = "Update the title";As you can see, the span tag remained unparsed; the <title> element's contents were treated as plain text and returned exactly as they appear in the title element.
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}