Defines the document title shown in browser tabs, bookmarks, history, search results, and screen reader announcements.
Description
The <title> element defines the document's name. It is the only required element inside <head> and serves as the primary identifier for the page across every browser surface: tabs, bookmarks, history, task switchers, and search engine results. Screen readers announce it first when a user lands on a page.
Beyond static identification, document.title is a live, writable property. This makes the browser tab a zero-UI status channel: prepend an emoji for state, a count for notifications, or cycle through animation frames for a loading indicator — all without touching the visible page.
Basic Example
<title>Page Title</title>
Format Patterns
VB uses the Page | Site convention. The page-specific part comes first so users scanning many tabs see the distinguishing content before it gets truncated.
<title>Page Title | Site Name</title>
| Pattern |
Example |
When to Use |
Page | Site |
Pricing | Acme Corp |
Default for most pages. The VB docs site builds its titles this way from page front matter; in your own site, generate it in your layout or head template. |
Site |
Acme Corp |
Homepage only, where the page name would be redundant. |
(n) Page | Site |
(3) Inbox | My App |
Notification count. The number draws the eye in a row of tabs. |
Emoji Page | Site |
✉️ New message | My App |
Status indicator. Works without JavaScript if the state is known at render time. |
Keep titles under 60 characters. Search engines truncate around that point, and shorter titles are easier for screen reader users to parse.
Static Emoji Status
The simplest form of tab status: prepend an emoji to the title in your HTML. No JavaScript required. This works for any state known at render time — connection status, build results, form state.
<title>🟢 Connected | Dashboard</title><title>🔴 Offline | Dashboard</title> <title>⏳ Uploading... | Files</title><title>✅ Upload complete | Files</title> <title>📬 (3) new | Inbox</title><title>⚠️ Action required | Settings</title>
Choose emoji that are visually distinct at small sizes. Colored circles, warning signs, and mail icons work well. Avoid emoji that look similar across platforms or require fine detail to distinguish.
Dynamic Title Updates
document.title is writable and updates the browser tab immediately. Use it for SPA route changes and notification badges.
<script>const originalTitle = document.title; function setPageTitle(pageName) { document.title = pageName + ' | My App';} function setNotificationCount(count) { document.title = count > 0 ? `(${count}) ${originalTitle}` : originalTitle;}</script>
<title>(3) Inbox | My App</title>
Animated Spinners
Cycle through an emoji sequence with setInterval to create a loading spinner directly in the browser tab. This is a progressive enhancement: the tab title stays readable text with a rotating prefix.
Use it sparingly. Some screen readers announce title changes, a cycling title is motion that users who ask for reduced motion did not opt into, and a long task is better served by a static prefix such as ⏳ Uploading… | Files. The utility below shows a static frame when prefers-reduced-motion: reduce matches, and guards against starting twice.
<script>const spinners = { moon: ['🌑', '🌒', '🌓', '🌔', '🌕', '🌖', '🌗', '🌘'], clock: ['🕛', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚'], earth: ['🌍', '🌎', '🌏'], braille: ['\u280B', '\u2819', '\u2839', '\u2838', '\u283C', '\u2834', '\u2826', '\u2827', '\u2807', '\u280F'], dots: ['\u22C5', '\u2219', '\u25CF', '\u2219'],}; const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)');const originalTitle = document.title;let timer = null;let isLoading = false; function startSpinner(type = 'moon') { isLoading = true; if (timer) return; const frames = spinners[type]; if (reduceMotion.matches) { document.title = '⏳ ' + originalTitle; return; } let i = 0; timer = setInterval(() => { document.title = frames[i++ % frames.length] + ' ' + originalTitle; }, 150);} function stopSpinner({ done = true } = {}) { clearInterval(timer); timer = null; if (done) isLoading = false; document.title = originalTitle;} startSpinner('clock');fetch('/api/data') .then((res) => res.json()) .then((data) => { stopSpinner(); }) .catch(() => { stopSpinner(); document.title = '⚠️ ' + originalTitle; });</script>
Spinner Sequences
These sequences animate smoothly in browser tabs. Choose based on the mood you want:
Braille dot spinners are monochrome and compact — they work best when you want a subtle, terminal-style indicator. Moon and clock emoji are more playful and visible at a glance.
Performance
Pause the spinner when the tab is hidden. The animation is invisible anyway, and clearing the interval avoids unnecessary work. isLoading remembers that the task is still running, so the spinner resumes when the tab comes back:
<script>document.addEventListener('visibilitychange', () => { if (document.hidden) { stopSpinner({ done: false }); } else if (isLoading) { startSpinner(); }});</script>
Browsers throttle timers in background tabs, so a hidden spinner would mostly stall anyway. An interval of 100–200ms is enough for a visible animation.
Badging API
The Badging API is the platform-native way to show a numeric badge on an installed PWA's icon in the dock or taskbar. It complements title-based indicators but does not replace them — the Badging API only works for installed web apps, while title updates work in every browser tab.
<script>if ('setAppBadge' in navigator) { navigator.setAppBadge(5); navigator.setAppBadge(); navigator.clearAppBadge(); } function setBadge(count) { const base = document.title.replace(/^\(\d+\)\s*/, ''); document.title = count > 0 ? `(${count}) ${base}` : base; if ('setAppBadge' in navigator) { count > 0 ? navigator.setAppBadge(count) : navigator.clearAppBadge(); }}</script>
| Approach |
Where It Shows |
Requires |
document.title |
Browser tab, task switcher, history |
Nothing (works everywhere) |
navigator.setAppBadge() |
App icon in dock/taskbar/home screen |
PWA install, HTTPS, browser support |
Use both together for the best coverage. The title fallback ensures uninstalled users still see the notification count.
Attributes
The <title> element has no element-specific attributes. It supports global attributes, though in practice none are commonly used on it.
Its content model is text only — no child elements, no HTML tags. The text between the opening and closing tags becomes the document's title.
Language and Direction
The document title takes its language and direction from <html lang dir>. Screen readers use lang to choose a voice, so a page in German needs <html lang="de"> for its title to be pronounced correctly.
In right-to-left pages the title is laid out right to left, so Page | Site reads from the right: the page name still comes first for the reader. Keep the separator between the two parts and do not reverse them by hand. When a title mixes scripts, such as an English product name in an Arabic title, the browser's bidi algorithm orders the runs; short neutral separators like | or – survive this better than arrows or brackets.
SVG <title>
Inside <svg>, <title> is a different element. It names the SVG or the shape it belongs to: it becomes the graphic's accessible name and, in most browsers, a hover tooltip. It must be the first child of its parent shape or <svg>, and it does not change the document title.
<svg role="img" viewBox="0 0 24 24" aria-labelledby="chart-title"> <title id="chart-title">Sales up 12% this quarter</title> </svg>
Decorative icons should have no <title> and carry aria-hidden="true" instead.
Accessibility
- First thing announced: Screen readers read the page title before any other content. It is the primary way a user identifies which page they have landed on.
- Unique per page: Every page must have a distinct title. Duplicate titles across pages make navigation impossible for screen reader users who rely on title differences to distinguish tabs and history entries.
- Page-specific content first: The
Page | Site format puts the distinguishing content first. A screen reader user scanning multiple tabs hears the unique part immediately rather than hearing the site name repeated for every tab.
- Emoji are announced: Screen readers read emoji by their Unicode name.
🕐 is announced as "one o'clock," 🌑 as "new moon." This is meaningful but can be verbose — avoid stacking multiple emoji in the title.
- Dynamic updates may be announced: Some screen readers announce title changes. A cycling spinner can cause a stream of announcements, so prefer a static prefix for long tasks, honour
prefers-reduced-motion, and use an aria-live region for important status messages rather than relying on title changes alone.
- Keep it concise: Aim for under 60 characters. Long titles are tedious to listen to and get truncated in visual UI.
- Avoid keyword stuffing: Titles like "Shoes | Buy Shoes | Best Shoes | Shoe Store" are frustrating for everyone and actively harmful for screen reader users who must listen to the entire string.
SEO
- Search engines display roughly 50–60 characters of the title in results. Put the most important words first.
- The title should match or closely reflect the page's
<h1> heading. Mismatches between the tab title and the visible heading confuse both users and search engines.
- Each page needs a unique title. Duplicate titles signal duplicate content to search crawlers.
- The
<title> and <meta name="description"> work as a pair — the title is the headline, the description is the summary. Make sure they complement each other.
- Dynamic emoji prefixes and notification counts do not affect SEO. Search engines index the server-rendered title, not JavaScript-modified values.
Browser Behavior
| Surface |
What Shows |
| Tab bar |
Title text, truncated to fit. Emoji render in color on macOS/iOS, monochrome on some Windows versions. |
| Bookmarks |
Title at the time of bookmarking. Does not update with document.title changes. |
| History |
Title at the time the history entry was created. SPA route changes should update document.title before calling history.pushState(). |
| Task switcher |
OS-level alt-tab and task views show the current document.title. |
| Search results |
Server-rendered title from the HTML source. JavaScript changes are not indexed. |
| Social previews |
og:title takes precedence. Falls back to <title> if no OG tag is present. |
Related
<head> — Parent element; the VB docs site generates its titles from page front matter
<meta> — description meta pairs with the title for search results
<link> — Canonical URL and favicon, which appear alongside the title in tabs
<html> — The lang and dir attributes on the root element set the title's language and direction
<svg> — SVG <title> names a graphic rather than the document