Topic 6.2
Titles and Meta Descriptions
In one line
The <title> names the page on tabs, bookmarks and search results, and the meta description is your suggested summary under it; both should be unique, specific and short enough not to be cut off.
Think of it like this
A book on a library shelf. Only the spine shows: a few words that must tell you what the book is so you pull it out. The back cover gives a short blurb that convinces you to read it. In search results, the <title> is the spine and the meta description is the back cover.
Words you'll meet
New words in this topic, in plain English. Come back here whenever one feels fuzzy.
- title
- The element with the page's name. It shows on the tab and as the headline in search results.
- Meta description
- A short summary in
<meta name="description">. Not shown on the page, often shown in search results. - SERP
- Search engine results page: the list of results you see after searching.
- Snippet
- The short text under a search result's title, describing the page.
- Title link
- The clickable headline of a search result, usually built from your
<title>. - Truncation
- Cutting text that is too long and adding
...at the end. - Keyword
- A word or phrase people type into a search engine.
- Single-page app
- A site that swaps content with JavaScript instead of loading a new page for each view.
Step by step
01Say what the page is
Start from the reader's question. Someone searching "egg free pancakes" should see those words early in your title.
Bad: Home. Bad: Asha's Kitchen | Recipes | Food | Cooking | Pancakes | Best. Good: Egg-Free Pancakes in 20 Minutes — Asha's Kitchen.
02Add the brand at the end
A separator (—, | or -) followed by the site name helps people recognise the source. Put it last, because the end is what gets cut off. The home page can lead with the brand.
<title>Egg-Free Pancakes in 20 Minutes — Asha's Kitchen</title>03Write the description for a human
One or two sentences: what's on the page and why it's worth the click. Mention specifics (time, price, count, version). Avoid double quotes inside it (they would end the content attribute; write " if you must), and never repeat the title word for word.
<meta name="description" content="Soft, fluffy pancakes without eggs, ready in 20 minutes. Includes a gluten-free swap and tips for cooking a big batch.">04Match the title and the h1
The <h1> is the visible headline on the page. It doesn't need to be identical to the title, but they should say the same thing. When they disagree, Google is more likely to rewrite your title link.
<h1>Egg-free pancakes in 20 minutes</h1>05Check how it will look
The live example below draws a search result from the page's own head and warns about lengths. Real tools: Google Search Console shows which queries bring people, and searching site:yourdomain.com shows your live results.
Try it yourself
- 1
Make the title too long
In the first example, change the title to
The Best Ever Easy Egg-Free Fluffy Vegan Breakfast Pancakes Recipe for Families — Asha's Kitchen. Predict what the console says and where the preview cuts it. Run and check. - 2
Remove the description
Delete the
<meta name="description">line and run. The script crashes: read the error and explain it. Then change the script to usedocument.querySelector('meta[name="description"]')?.content ?? "(Google would pick text from the page)". - 3
Look at real results
Search for something you know well. For three results, compare the title link with the page's real
<title>(open the page and look at the tab). Did any get rewritten?
Code & diagrams
Real engines cut by pixel width, not by character count; 60 and 160 characters are good rules of thumb.
Preview
Console
Nothing logged yet.Expected console output
Title length: 48 ok
Description length: 118 okThe getter trimmed and collapsed the messy whitespace. Click the button to see the title change again; in a real tab, the tab text would update.
Preview
Console
Nothing logged yet.Expected console output
Tidied title: Inbox — Mailo
After update: (2) Inbox — MailoBreak it on purpose
Errors are the best teachers. Make each change, read the error, guess what went wrong, then reveal the answer.
Break #1
The same title on every page
Give every page of a site <title>Asha's Kitchen</title>.
Break #2
A missing description crashes the script
In the first example, delete the description meta tag.
Myth vs fact
Myth
The meta description boosts your ranking.
Fact
It doesn't affect ranking directly. It affects how many people click your result, which is why it is still worth writing well.
Myth
<meta name="keywords"> helps SEO.
Fact
Google ignores it. Put the words people search for in your title, headings and text instead.
Myth
Google always shows exactly my title and description.
Fact
Google may rewrite the title link and often picks a snippet from your page text to match the search. Accurate, specific tags get kept more often.
Pro corner
Extra depth for experienced readers. New to this? Skip it for now and come back later.
- ▸
Google's title-link system (changed in 2021) can use the
<title>, the main visible heading, other prominent headings, anchor text from links pointing to the page, andog:title. Mismatched or boilerplate titles are the usual cause of rewrites. - ▸
Truncation is by pixel width:
WWWWis much wider thaniiii. Mobile and desktop SERPs differ, and so do Bing and DuckDuckGo. Treat 60 and 160 characters as guides, not limits; nothing breaks if you go over, the end is just hidden. - ▸
Accessibility: WCAG 2.4.2 (Page Titled) requires titles that describe the topic or purpose. For single-page apps, update
document.titleon every route change and move focus to the new<h1>so screen-reader users notice the change. - ▸
max-snippet:[n],nosnippetanddata-nosnippetcontrol snippets for Google. Note thatdata-nosnippetonly works onspan,divandsectionelements.
Remember this
- 1
The
<title>element is required in every page and there must be only one. It shows in the browser tab, in bookmarks and history, as the headline of a search result, as the fallback headline when a link is shared, and it is the first thing a screen reader announces when the page opens. A search result is one entry in the list a search engine shows; the page of results is called the SERP (search engine results page). - 2
A good title says what this page is, most important words first, then the site name:
Pancake Recipes: Fluffy, Easy and Egg-Free — Asha's Kitchen. Google cuts titles that are wider than about 600 pixels, roughly 50–60 characters, and adds.... Put the words people search for at the start so they survive the cut. Every page needs its own title: a site where every page is titledHomeis impossible to tell apart in tabs or results. - 3
<meta name="description" content="...">is a one- or two-sentence summary of the page. It is not shown on the page itself. Search engines often use it as the snippet, the grey text under the title. Aim for roughly 120–160 characters, written for a human: say what the reader gets, include the main words they'd search, and make each page's description unique. - 4
Search engines may rewrite both. Google builds the title link from your
<title>, but may use the main heading, link text or other text if your title is missing, too long, stuffed with keywords or the same on many pages. The snippet is often chosen from the page's text to match the person's search. You control them best by writing an accurate title that matches your<h1>and a description that truly summarises the page. - 5
The description has no direct effect on ranking; it affects whether people click. The old
<meta name="keywords">tag is ignored by Google and has been for years; don't spend time on it. Robots directives can also limit snippets:<meta name="robots" content="max-snippet:50">or thedata-nosnippetattribute on an element (more in Topic 6.7). - 6
JavaScript can change the title with
document.title = "(3) Inbox". Single-page apps (sites that change content without loading a new page) must do this on every view change, otherwise the tab and screen reader announcements show a stale name. Thedocument.titlegetter also tidies the text: it trims spaces at both ends and collapses runs of whitespace into one space.
Explain it without notes
Name five places where a page's <title> is used.
What makes a good title for a recipe page, and why does word order matter?
Does the meta description affect ranking? Why write one anyway?
Why might Google show a different title than the one you wrote?
Practice
Write a title and a meta description for a page that sells a blue cotton school bag for ₹899 on a shop called BagBazaar.
Write a JavaScript function setUnread(n) that sets the title to Inbox — Mailo when n is 0 and to (n) Inbox — Mailo otherwise. Call it with 0 and 5 and log the title.
Trade-offs
- ↔
Including the brand in every title builds recognition but uses up the 60 characters; on long titles, drop the brand (Hectal's own
pageMeta()does exactly this). - ↔
A hand-written description per page is the best quality but doesn't scale to thousands of pages; generate them from structured data (price, rating, summary) and hand-write the most important pages.
Done when you can
I can write a unique, specific title with the brand at the end.
I can write a 120–160 character description for a human reader.
I know the description doesn't affect ranking but does affect clicks.
I know why Google rewrites titles and how to avoid it.
I can update
document.titlefrom JavaScript.