Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Clarify behavior of HTML tags within the <title> element (Issue #36702) #36827

Merged
merged 14 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions files/en-us/web/api/htmltitleelement/text/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ browser-compat: api.HTMLTitleElement.text

{{APIRef("HTML DOM")}}

The **`text`** property of the {{domxref("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.
The **`text`** property of the {{domxref("HTMLTitleElement")}} interface represents the plain text content of the document's title. It only contains text; if HTML tags are included within the `title` element, they are treated as plain text rather than being interpreted as HTML.

## Value

Expand All @@ -32,10 +32,10 @@ Consider the example below:

```js
const title = document.querySelector("title");
console.log(title.text); // yield: "Hello world! really?"
console.log(title.text); // yield: "Hello world! <span class="highlight">Isn't this wonderful</span> really?"
```

As you can see, the tag `span` and its content were skipped.
As you can see, the `span` tag and its content were treated as plain text and displayed exactly as they appear in the `title` element, rather than being processed as HTML.

## Specifications

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/html/element/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Metadata contains information about the page. This includes information about st
| {{HTMLElement("link")}} | Specifies relationships between the current document and an external resource. This element is most commonly used to link to CSS but is also used to establish site icons (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things. |
| {{HTMLElement("meta")}} | Represents {{Glossary("Metadata","metadata")}} that cannot be represented by other HTML meta-related elements, like {{HTMLElement("base")}}, {{HTMLElement("link")}}, {{HTMLElement("script")}}, {{HTMLElement("style")}} and {{HTMLElement("title")}}. |
| {{HTMLElement("style")}} | Contains style information for a document or part of a document. It contains CSS, which is applied to the contents of the document containing this element. |
| {{HTMLElement("title")}} | Defines the document's title that is shown in a {{glossary("Browser", "browser")}}'s title bar or a page's tab. It only contains text; tags within the element are ignored. |
| {{HTMLElement("title")}} | Defines the document's title that is shown in a {{glossary("Browser", "browser")}}'s title bar or a page's tab. It only contains text; html tags within the element are also treated as a plain text. |

## Sectioning root

Expand Down