What is the <title> element in HTML?

The <title> element contains the document’s title that is displayed in the browser tab. Any HTML document must contain a <title> element.

An HTML document can only contain a single <title> element. Only text is rendered within the <title> element.

The <title> element must always be used within the document’s <head> element.

Titles and search engines

Search engine algorithms use the <title> element to decide the relevance of a document when listing pages for a search query.

To ensure that your document reaches the right audience, you must ensure that the title of your page (contained within the <title> element) is as accurate and purposeful as possible.

You should use a descriptive phrase as your title instead of a short one or two-word title. However, search engines display about 556055-60 characters of the title, so you must ensure that the text within the <title> element does not exceed that range. You should also ensure that your title is as unique as possible, as duplicate titles often lead to inaccurate search results.

Attributes and events

The <title> element includes only global attributes.

Example

The code below shows how the <title> element works in HTML:

Explanation

The <title> element in line 44 contains the text that serves as the document’s title in browser tabs and search engines.

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved