The HTML head is the <head> section at the top of a web page that holds information for machines rather than readers, such as the page title, the character set, the description, the canonical address, style sheets and scripts. Visitors never see most of it. Search engines, browsers, social networks and AI bots read it first to decide what the page is and how to treat it.
What is the HTML head? #
Every HTML page has 2 main parts: the head and the body. The body is what people read. MDN’s reference for the head element says it holds machine-readable information about the document, like its title, scripts and style sheets. It must be the first child of the html element, and a page has only 1 head.
A short, healthy head looks like this:
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Walking boots for wide feet | Example Shop</title>
<meta name="description" content="Wide-fit walking boots in sizes 6 to 13, with free UK returns.">
<link rel="canonical" href="https://www.example.co.uk/boots/wide-fit/">
<meta property="og:title" content="Walking boots for wide feet">
<link rel="stylesheet" href="https://www.example.co.uk/style.css">
</head>
What can go in the head? #
MDN and Google agree on the list. Google’s page on valid page metadata names 8 valid elements:
| Element | What it does | Search example |
|---|---|---|
title |
The page’s name | Often used for the title tag link in results |
meta |
Named facts about the page | meta description, meta robots tag, viewport |
link |
Links to other files or versions | canonical tag, hreflang, favicon |
script |
Code, or data | JSON-LD structured data |
style |
Styling rules | Small blocks of CSS |
base |
Base address for relative links | Rare; easy to get wrong |
noscript |
Fallback when scripts are off | Tracking pixels |
template |
Markup kept for later use | Rare in the head |
MDN says a normal page needs exactly 1 title in the head.
Why does it matter for search? #
Several signals Google relies on live here, and some only work here:
- Canonical. Google’s guide to duplicate URLs says the
rel="canonical"link element is only accepted if it appears in the head. - Title. Google’s title link guide says the
titleelement is one source for the link in results, alongside headings,og:titleand link text. - Robots. Google’s robots meta tag guide says the tag belongs in the head, though Google does not enforce placement and also reads it in the body. For non-HTML files, the same rules go in an X-Robots-Tag header instead.
What breaks the head for Google? #
This is the trap most owners never hear about. Google’s metadata page says that if an invalid element, such as an iframe or img, appears in the head, Google assumes the head has ended and ignores the elements after it. A canonical tag or robots tag placed below that point may never be read.
Invalid elements often arrive by accident: a plugin adds an image pixel, a chat widget adds an iframe, or a broken template leaves a stray tag. Google’s advice is to avoid them, or, if you must, place them after everything you want Google to see.
Why does it matter for AI answers? #
AI crawlers and agents read the head too. The title and description are short summaries of the page, and Open Graph tags offer a name, description and picture for any service that builds a link preview. Robots rules in the head decide whether a page can be indexed and shown. A head that says 1 thing while the body says another gives an AI agent mixed facts. Keep both telling the same story.
Does the order matter? #
Yes, in 2 ways. First, MDN’s page on the meta element says the character set declaration must sit within the first 1024 bytes of the document, so put <meta charset="utf-8"> first. Second, because of the invalid element rule above, put your search tags early and any widget code late. For speed, large scripts in the head can slow the first paint; see render-blocking resources and async and defer scripts.
Common mistakes #
- 2 canonical tags. A theme adds 1 and an SEO plugin adds another, pointing at different addresses.
- A stray image or iframe at the top of the head. Everything below it may be ignored by Google.
- A missing or duplicate title. Each page needs its own.
- Different heads on mobile and desktop. Google’s mobile-first indexing guide asks for equivalent title and meta description on both versions.
- A leftover noindex. A staging setting copied to the live site hides it from search. See noindex.
A worked example #
A garden centre adds a live chat widget. Weeks later, Google starts showing the wrong version of its plant pages. The owner views the page source. The chat code put an iframe near the top of the head, above the canonical tag. Under Google’s rule, the head ends at the iframe, so the canonical tag is not read.
The fix is to move the widget code to the end of the body. The owner then checks the live page with URL Inspection in Search Console and waits for the pages to be crawled again.
How to check it #
- View the page source and read the head from the top. Note any
imgoriframe. - Run our meta tag checker to list the title, description and robots tags; the meta tag checker guide explains each one.
- Confirm 1 canonical with our canonical checker.
- Check language versions with our hreflang checker and share previews with our Open Graph checker.
- Check robots rules sent as headers with our HTTP header checker.
Questions #
Is the head the same as HTTP headers? #
No. The head is part of the page. HTTP headers travel with the file before the page itself.
Can I skip the head tags? #
MDN says the start and end tags can be left out in some cases, but writing them makes the page easier to check.
Related words #
Sources #
- MDN: the head element, checked 25 November 2026
- MDN: the meta element, checked 25 November 2026
- Google Search Central: use valid page metadata, checked 25 November 2026
- Google Search Central: consolidate duplicate URLs, checked 25 November 2026
- Google Search Central: influencing title links, checked 25 November 2026
- Google Search Central: robots meta tag specifications, checked 25 November 2026
- Google Search Central: mobile-first indexing best practices, checked 25 November 2026
Updated 25 November 2026 by URSY.
Cite this page: HTML head. URSY. Updated 25 November 2026. https://ursy.com/wiki/html-head/ · Section links
Tools for this
- LiveCitation Anchor Checkerdo your headings have stable links AI can cite?Run the check →
- LiveHeading Checker (H1-H6 outline)Run the check →
- LiveHTTP Header Checker (cache, status, X-Robots-Tag)Run the check →
- LiveSecurity Headers CheckerRun the check →
- ProCitation anchors managerStable heading links site-wide; retired ones kept workingIn URSY Pro →