W3docs

HTML <title> Tag

The HTML <title> tag defines a title of an HTML document. The title is displayed in the browser toolbar and on search engine results pages.

The HTML <title> tag defines the title of a document. It is a piece of document metadata: it does not appear anywhere inside the page itself, but it controls how the page is labelled everywhere the page is referenced — the browser tab, a bookmark, a search result, and a shared social-media link.

This page explains why every page needs exactly one <title>, where it must go, and how to write one that works well for both users and search engines.

Why the <title> matters

The <title> is one of the few elements that is required in a valid HTML document. Browsers and search engines treat it as the canonical, human-readable name of the page, so it shows up in many places at once:

  • Browser tab / window — the text on the tab is the page's title.
  • Bookmarks — when a user bookmarks the page, the title becomes the default bookmark name.
  • Search results (SERPs) — the title is usually used as the blue, clickable headline of the result, so it strongly affects your click-through rate.
  • Social shares — when a link is posted to a chat app or social network, the title is pulled into the link preview card (alongside meta tags such as Open Graph).
  • Accessibility — screen readers announce the title when a page loads, helping users confirm where they are.

Because so many tools consume it, a clear, accurate title improves both UX (people recognise the right tab or result) and SEO (search engines rank the page for relevant queries).

Tip

The title should contain the page's most important keywords so that search engines rank the page for relevant queries — but write it for humans first.

Where it goes: exactly one, inside <head>

The <title> must live inside the <head> section, which is where document metadata belongs, and a document must contain exactly one <title>. The <head> holds information about the page (title, character set, viewport, meta data) rather than visible content, so the title naturally sits there with the rest of the page's descriptive data.

Syntax

The <title> element comes in pairs. The text is written between the opening <title> and closing </title> tags, and it may contain text only — no other HTML elements.

Example of the HTML <title> tag:

HTML <title> Tag

<!DOCTYPE html>
<html>
  <head>
    <title>W3Docs - learn HTML, CSS, PHP, JavaScript online.</title>
  </head>
  <body>
    <p>The main content of the page.</p>
  </body>
</html>

Writing a good title: weak vs. optimized

A vague or missing title forces browsers to fall back to the URL, and search engines may rewrite or ignore it. Compare the two pages below.

Weak title — too short and generic:

<head>
  <title>Home</title>
</head>

Optimized title — descriptive, with the Page Name | Site Name pattern:

<head>
  <title>HTML &lt;title&gt; Tag: Syntax, SEO and Examples | W3Docs</title>
</head>

The Page Name | Site Name template is a common, reliable convention: the unique, keyword-rich part of the title comes first (where it is most visible in a search result and on a narrow browser tab), and the site name comes last for brand recognition. A pipe (|) or dash (-) is the usual separator.

Practical guidelines

  • Keep it around 55–60 characters. This is a guideline, not a hard limit — search engines truncate long titles, so put the important words near the start.
  • Be descriptive. Avoid one- or two-word titles; use a meaningful phrase that summarises the page.
  • Make every title unique across your site so each page is distinguishable in tabs and search results.
  • Avoid keyword stuffing. A list of words reads as spam and helps no one.
  • Avoid unusual special characters, which different browsers may render inconsistently.

Attributes

The <title> tag supports the Global Attributes. In practice, only lang is meaningful — it declares the language of the title text, which helps when the title differs from the document language. Attributes such as id, class, and style are accepted by the parser but have no effect, because the title is never rendered inside the page where styling or scripting could apply.

Practice

Practice
Which statement about the HTML title tag is correct?
Which statement about the HTML title tag is correct?
Was this page helpful?