<head> & <title> Tags in HTML

Quick facts

Category<head>: none (it’s the first child of <html>). <title>: metadata content
Content model<head>: metadata content, including exactly one <title>. <title>: text only
Tag omission<head> tags can technically be omitted (the browser adds them), but writing them is best practice. <title> needs both tags
Permitted parents<head>: <html>, as its first child. <title>: A <head> element
DOM interfacesHTMLHeadElement, HTMLTitleElement

Syntax

<head> <meta charset="UTF-8"> <title>Chocolate Cake Recipe – Easy &amp; Moist | Baking Club</title> </head>

Live example

Edit the code below and watch the preview update instantly.

index.html
Preview

Attributes

AttributeDescription
—Both elements accept only the global attributes. The old profile attribute on <head> is obsolete.

Common examples

A complete head for a modern page

Charset first, then viewport, title and description — the essentials every page needs.

<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Chocolate Chip Cookies Recipe | Sam's Kitchen</title> <meta name="description" content="Soft, chewy cookies in 25 minutes."> <link rel="icon" href="/favicon.svg"> <link rel="stylesheet" href="/css/style.css"> </head>

Good title patterns

Put the most specific words first and your brand last.

<!-- Article --> <title>How to Center a Div in CSS | Web Basics</title> <!-- Product --> <title>Blue Running Shoes – Size 6-12 | ShoeShop</title> <!-- Homepage --> <title>ShoeShop – Running Shoes &amp; Trainers Online</title>

Changing the title with JavaScript

Apps can update the tab title to show new messages or the current step.

<script> document.title = "(3) Inbox | MyMail"; </script>

<title> vs og:title

The <title> is used in the browser tab, bookmarks and usually as the blue link in Google results. The og:title meta tag is used when the page is shared on social networks and messaging apps.

They can be the same, but they don’t have to be: a search title is often keyword-focused (“HTML Cheat Sheet – All Tags with Examples”), while a social title can be more conversational (“Every HTML tag on one page”). If og:title is missing, most platforms fall back to the <title>.

<title>og:title
Shown inBrowser tab, Google resultsSocial & chat previews
RequiredYesNo (recommended)
StyleKeyword-focusedClick-friendly

Common mistakes to avoid

  • The same title on every page. Each page needs its own title that describes that page.
  • Titles that are too long. Google cuts them off around 60 characters; put the important words first.
  • Visible content in the head. Text, images or headings in the <head> are moved into the body by the browser and can break the page.
  • Keyword stuffing. “Shoes, Cheap Shoes, Buy Shoes” looks like spam and rarely gets clicked.

Accessibility & SEO tips

  • Screen readers announce the title when a page opens, so it should tell visitors where they are.
  • Google sometimes rewrites titles that are vague or stuffed with keywords — a clear, honest title is more likely to be shown as written.
  • On WordPress, SEO plugins such as Yoast let you set a search title separately from the page heading.

Browser support

Supported in every browser, including Chrome, Edge, Firefox, Safari and their mobile versions — it has been part of HTML since the very first versions.

Related tags

Frequently asked questions

How long should an HTML page title be?
Aim for about 50–60 characters. Google cuts off longer titles in search results (by pixel width, roughly 600 pixels), so put the most important words first and keep the brand name at the end.
What is the difference between <title> and <h1>?
The <title> appears in the browser tab and search results, not on the page. The <h1> is the main heading visible on the page. They often say similar things, but the title can be shorter and include your site name.
What goes in the <head> of an HTML page?
Metadata that browsers and search engines use: <meta charset>, the viewport <meta> for mobile, <title>, a <meta name="description">, <link> tags for stylesheets and icons, and <script> tags (usually with defer).
Can a page have two <title> tags?
No. Only one title is allowed; if there are two, browsers and search engines usually use the first and ignore the second.
Why does Google show a different title than mine?
Google rewrites titles it thinks are too long, vague or don't match the page. A short, specific title that matches the main heading is usually kept.
Does the order of tags in the <head> matter?
Mostly not, but <meta charset> should come first, and stylesheets before scripts helps the page appear faster.