Title Tag in HTML: Syntax, Length and SEO Examples

November 11, 2026 · 11 min read

Title Tag in HTML: Syntax, Ideal Length and SEO Examples

The HTML title tag is the <title> element in a page's <head>, and it names the document. Browsers show it in the tab, and Google uses it as a main source for the clickable headline in search results. This guide covers the exact syntax rules, before-and-after examples, length checks and why Google sometimes rewrites your title.

What Is the Purpose of a Title Tag?

A page title tells people and software what a page is about before they read a word of it. Here's the whole thing in context:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>How to Back Up a Postgres Database | Acme Blog</title>
</head>
<body>
  ...
</body>
</html>

That one line of text turns up in several places:

  • The browser tab and window title bar, so you can tell open tabs apart.
  • Bookmarks and history, where it becomes the default name of the saved page.
  • Search results. Google's title link documentation lists <title> content first among its sources, followed by the main visible title, <h1> headings, og:title and others.
  • Assistive technology. WCAG 2.4.2 Page Titled is a Level A requirement: pages need titles that describe their topic or purpose.

SEO plugins often call it the meta title, and lists of meta title tags usually include it. It isn't a <meta> element, though. It's a separate element with its own parsing rules. Many social platforms read an og:title property first and fall back to the page title when it's missing. Our guide to meta tags for SEO covers the real <meta> elements that sit beside the title in the head.

Where Is the Title Tag Placed? Syntax Rules Browsers Enforce

The element goes inside <head>, and a normal HTML document has exactly one. The WHATWG HTML spec makes it required, with narrow exceptions such as an iframe srcdoc document or an email where the subject line already supplies the title.

Four rules trip people up:

  1. Text only. The spec treats it as an escapable raw text element. Character references like &amp; get decoded, but tags don't. Per MDN, any HTML inside it is shown as plain text.
  2. Escape the ampersand. Writing &amp; in source is always safe, and the tab displays a plain &.
  3. Whitespace collapses. The document.title getter strips leading and trailing whitespace and collapses runs of it, so line breaks in your source don't show up in the tab.
  4. Close it. MDN warns that leaving off </title> should cause the browser to ignore the rest of the page, because everything after the opening tag becomes title text.

Here are two alternative titles for the same page. Only one would ever go in a real document:

<title>Q&amp;A: Pricing and Refunds | Acme</title>
<title>Q&amp;A: <strong>Pricing</strong> | Acme</title>

In the tab, the first line displays as Q&A: Pricing and Refunds | Acme. The second shows the literal characters <strong>Pricing</strong> in the tab, tags and all, because markup inside a title is never parsed.

The text inside the title tag vs the title attribute

A search for "tag in title" can mean either of two different things that share a name. The <title> element names the whole document. The title attribute, as in <abbr title="HyperText Markup Language">HTML</abbr>, is a global attribute that adds advisory text to one element, which most desktop browsers show as a hover tooltip. MDN's title attribute reference notes it's hard to reach for touch and keyboard users, and it plays no part in your page title.

One more trap if you write in Markdown: there's no title syntax in Markdown itself. A # Heading becomes an <h1> in the body, not a <title> in the head. Our Markdown vs HTML comparison explains where Markdown's job ends and HTML's begins.

What Is a Title Tag Example? Six Page Types, Before and After

A strong title names the specific thing on the page first, adds the qualifier a searcher cares about, and puts the brand last. Here are six weak titles rewritten for invented sites, with character counts:

Blog post
  weak:   Blog | Acme                                            (11)
  better: How to Back Up a Postgres Database | Acme Blog         (46)

Docs page
  weak:   Installation                                           (12)
  better: Install the Acme CLI on macOS and Linux | Acme Docs    (51)

Product page
  weak:   Product | Northwind                                    (19)
  better: Trail 2 Waterproof Hiking Boots for Men | Northwind    (51)

Category page
  weak:   Shoes                                                  (5)
  better: Women's Running Shoes for Road and Trail | Northwind   (52)

Homepage
  weak:   Home                                                   (4)
  better: Acme: Invoicing Software for Freelancers               (40)

Local service page
  weak:   Plumber Denver Plumbers Cheap Plumber Denver CO        (47)
  better: Emergency Plumber in Denver, CO | Northwind Plumbing   (52)

The weak versions fail in different ways. Most are too vague to tell apart in a row of tabs, and the plumber one is a keyword list. The homepage is the one place where the brand leads, because the brand is the topic. Title case or sentence case both work; pick one and stay consistent.

How Long Should a Title Tag Be? Using a Title Length Checker

Google's documentation says there's no limit on how long a <title> element can be. What gets cut is the title link in search results, which Google truncates as needed, typically to fit the device width. So length is a display question, not a validity one.

The common rule of thumb is about 50 to 60 characters. W3Schools says search engines display about 50-60 characters, and MDN says about the first 55-60. Because truncation depends on rendered width, a title full of wide letters like W and M gets cut sooner than one full of narrow letters like i and l. A character count is a proxy, not a guarantee.

That's why any meta title checker gives you an estimate. A practical workflow with free tools:

  1. Paste your draft title into the online Markdown editor. The status bar shows a live character count as you edit.
  2. Open the meta tag generator, enter the title and read its SERP preview. It estimates pixel widths from approximate Arial glyph widths, so treat it as a title length checker that's close, not exact.
  3. Front-load the words that matter, so a cut at either width still leaves the topic readable.

The generator works only on the text you type. It doesn't crawl your live site or check rankings. To read a published page's current title, open the browser console and run document.title. For the other tags in a live page's head, follow our steps to check meta tags.

Why Google Rewrites Your Title and How to Stop It

Google doesn't always show your title as written. Its title link documentation lists seven common issues. For most of them, Google builds the title link from other text on the page. For the last one, it may just omit the site name:

Google's documented triggerWhat it looks likeFix
Half-empty titleJust a separator and the site name, with no topicPut the page's actual topic before the brand
Obsolete titleAn old year in the title while the page shows a newer oneUpdate the title whenever the visible date changes
Inaccurate titleA title that doesn't describe the content, such as a list of keywordsDescribe what's actually on the page
Micro-boilerplateMany pages share one title, like TV episodes with no season numberAdd the detail that tells pages apart
No clear main titleSeveral large headings look equally prominentMake one heading the clear main title
Language or script mismatchTitle in one language or script, content in anotherWrite the title in the page's main language
Repeated site nameThe site name repeats what Google already shows in the resultKeep the brand short, or accept that Google may drop it

Google also tells you to avoid keyword stuffing, and suggests putting the site name at the start or end, separated by a delimiter such as a hyphen, colon or pipe. We prefer topic first, brand last, joined by a pipe. It's easy to scan and survives truncation better than a brand-first title.

There's a limitation you can't engineer around: you can't force Google to display your exact title. After you change it, Google has to recrawl and reprocess the page, which its docs say may take a few days to a few weeks.

Title Tag vs H1: Do They Need to Match?

They should agree, but they don't need to be identical. Google recommends making the main title clear on the page, for example by putting it in the first visible <h1>. A page title that contradicts the visible heading invites the kind of rewrite shown in the table above.

In practice, the H1 can be longer and more conversational because nothing truncates it. The title tag can be tighter and carry the brand. For heading structure and H1 rules, see our guide to Markdown headings.

Setting the Title Tag From Markdown Front Matter

If you write in Markdown for a static site generator, you rarely type a <title> by hand. You set title in the front matter, and the site's layout or theme writes the element. Our Markdown front matter guide covers the YAML syntax itself.

---
title: How to Back Up a Postgres Database
---

With a layout that appends the site name, that front matter typically becomes:

<title>How to Back Up a Postgres Database | Acme Blog</title>

How each tool gets there:

  • Jekyll with jekyll-seo-tag. Add the {% seo %} tag to your layout. Its source joins the page title and the site title from _config.yml with a spaced pipe, as in Page Title | Site Title. Use {% seo title=false %} to turn the title output off.
  • Hugo. .Title returns the front matter title. What lands in the head depends on your theme's template, often something like {{ .Title }} | {{ .Site.Title }}.
  • Docusaurus. If you leave out the front matter title, it falls back to the doc's Markdown title (or its ID). The site config's titleDelimiter, a pipe by default, is the delimiter used in the generated <title>.
  • Pandoc. With --standalone, the title comes from the pagetitle metadata, which equals title by default. The --title-prefix option adds a prefix to the head title only.

On WordPress, your theme or an SEO plugin writes the element from the post title or a custom SEO title field. Our editor's preview doesn't render front matter, so it can't show you the resulting title. Check the final <title> in your built HTML.

Title Tag FAQ

A good title tag is one escaped line of text in the head. It names the page first and the brand last, stays readable at around 50 to 60 characters, and agrees with the page's main heading. Draft it in the editor to watch the character count, then preview the result in the meta tag generator before you ship it.