Sub topic 3
The title tag
This chapter covers what the <title> element is, how search engines and browsers use it, and the errors that cause trouble in practice. It assumes you know basic HTML structure (head and body), how URLs and query strings work, and what a search results page looks like. Chapter 4 covers how to write good titles. This chapter covers the mechanics.
What the title element is
The <title> element sits in the document <head> and holds a short piece of text that names the page. HTML requires exactly one <title> element per document, and it may contain only text. Tags inside it are not parsed as markup.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Trail Running Shoes for Beginners | Example Store</title>
</head>
<body>
<h1>Trail Running Shoes for Beginners</h1>
</body>
</html>The browser does not render the title inside the page body. It uses the title in several other places:
- The browser tab and window title.
- Bookmarks and browser history entries.
- The accessible name that screen readers announce when a page loads.
- Share dialogs and some link previews, as a fallback when no other title is declared.
- Search results, where it usually becomes the blue clickable headline.
The last use is the one that matters for search. The title is the strongest short description of the page that you control, and it is the first thing a searcher reads.
How the title fits into search
A search engine processes a page in stages: it crawls the URL, renders and parses the HTML, indexes the content and metadata, and later builds a result when a query matches. The title is read at the parse stage and stored with the page. At query time the engine decides which text to show as the headline.
Two points follow from this flow:
- The title is a signal about what the page is about, so it contributes to ranking. It is one signal among many, and it does not work as a keyword slot to fill.
- The title you write is a suggestion for the headline. The engine can show something else. Chapter 8 covers why that happens.
Anatomy of a good-enough title
A title has a few parts you control:
- Primary descriptor: the words that say what this specific page is.
- Qualifier: optional words that narrow the topic, such as an audience or a year.
- Brand: usually the site name, often at the end.
- Separator: a character such as
|,-, or:between parts.
In Trail Running Shoes for Beginners | Example Store, the descriptor and qualifier are Trail Running Shoes for Beginners, the separator is |, and the brand is Example Store. Put the page-specific words first. Brand text at the front uses up the space that is most likely to be shown and read.
Length and truncation
Search engines do not enforce a character limit on titles. They limit the pixel width of the headline on the results page. The limit depends on the device, the font, and the characters in the title, because a W is wider than an i. Titles that run past the limit are cut off with an ellipsis.
A working rule is to keep the important words within roughly 50 to 60 characters. Treat that number as an estimate and not a guarantee. The full title is still read and indexed even when the display is cut, so words past the cut are not lost for matching. They are only invisible to the searcher.
| Title | Approx. length | Risk | Column |
|---|---|---|---|
| Trail Running Shoes for Beginners \ | Example Store | 49 | Fits on most displays |
| Example Store \ | The Best Place Online to Buy Trail Running Shoes for Beginners and Experts | 88 | Key words fall in the cut-off tail |
| Shoes | 5 | Too vague to distinguish the page |
The title and the h1 are different elements
New developers often assume the <title> and the <h1> must be identical. They do different jobs. The <title> appears outside the page, in tabs and results. The <h1> appears inside the page as its visible heading.
They should agree in topic. A page whose title promises one thing and whose heading says another confuses visitors and gives engines a reason to rewrite the title. They do not have to match word for word. A title often adds the brand or a qualifier that would look repetitive as a visible heading.
Common errors
Most title problems fall into a short list.
Missing or empty title
If the <title> is absent or empty, browsers show the URL in the tab, and search engines generate a headline from other text on the page. The result is often poor. Template bugs that render <title></title> when a data field is null are a typical cause.
Duplicate titles
When many pages share one title, such as every product page showing Product | Example Store, searchers cannot tell the results apart, and the engine has less to work with when it decides which page matches a query. Duplicates usually come from a template that uses a fixed string instead of page data. Pagination and filtered listing pages are also common sources.
More than one title element
Only the first <title> in the document is used as the document title by browsers. A second one can appear when a plugin or a component injects its own title into a template that already has one. Search engines may pick either one, which makes the result unpredictable. Make sure one source owns the title.
Title set only by JavaScript
Single-page applications often set document.title after the page loads. Search engines that render JavaScript can usually see it, but rendering happens later than the first fetch, and other crawlers and link-preview bots do not run scripts at all. If the title matters for search or sharing, include it in the server-delivered HTML.
// Fine for the tab after navigation, but not enough on its own:
document.title = "Trail Running Shoes for Beginners | Example Store";Keyword stuffing
A title like Trail Shoes, Running Shoes, Cheap Shoes, Best Shoes, Buy Shoes reads as spam to people and to engines. It is a common trigger for rewrites and can lower trust in the page. One clear phrase is enough.
Title that does not match the content
A title that promises something the page does not deliver leads to quick exits from the page and to rewriting. Write the title after you know what the page contains.
Special characters
Characters such as &, <, and quotation marks in a title should be escaped in HTML (&, <). Without escaping, a stray < can break parsing of the head. Most template engines escape values by default, but check that yours does when you build titles from user-supplied data such as product names.
<title>Salt & Pepper Grinders | Example Store</title>Checking a title
You can check titles without special tools.
- Open the page and view the source. Search for
<title. There should be exactly one match in the head. - Compare the title with the
<h1>and the page content. They should describe the same thing. - Search for the page in a search engine with
site:and the URL or a distinctive phrase to see what headline is shown. If it differs from your title, note how. - Use the engine's inspection tool in its webmaster console to see the indexed version of the page and confirm that the title was read from the HTML you serve.
Summary of rules
- Every indexable page gets one
<title>, and its text is unique across the site. - Put the page-specific words first and the brand last.
- Keep the important part inside about 60 characters, and accept that the cut-off point varies.
- Deliver the title in the initial HTML, not only through JavaScript.
- Escape special characters.
- Treat the title as a proposal. The engine can display different text.
Exercise
A product template renders <title>{{ product.name }} | Example Store</title>. For some products the name field is empty, and several pages end up showing | Example Store in search results. Name two problems this causes and one way to fix it in the template.
Show answer
The pages have an empty descriptor, so searchers cannot tell what each page is, and many pages now share the same title, which makes them duplicates. The engine will probably also rewrite the headline from other page text. A fix is to fall back to another field, for example {{ product.name or product.category }}, or to fail the build or log an error when the name is empty so the page does not ship with a blank title.
Exercise
A page has <title>Example Store | Trail Running Shoes for Beginners: Cushioned, Lightweight, Waterproof, and Affordable</title>. What will probably happen on the results page, and how would you restructure it?
Show answer
The title is long, so the end will probably be cut off with an ellipsis, and the brand at the front uses up the most visible space. Restructure it with the page-specific words first and the brand last, for example Trail Running Shoes for Beginners | Example Store, and move the extra detail into the page content and meta description.