HTML meta element

Reference for the HTML meta element, with related head, title, and link rules: charset placement, viewport zoom, description, canonical, and robots.

タグページの本文は現在英語です。

The meta element represents metadata that cannot be expressed with title, link, or other dedicated elements. This page deepens the catalog card for <meta> and also covers related head, title, and link rules, especially rel="canonical". Those elements do not get separate thin pages.

meta is a void element: it has no end tag and no children. It belongs in the document head. title provides the document title used in browser UI and as a default for many sharing contexts. link expresses relationships to other resources, including canonical URLs and stylesheets.

Examples are complete head fragments. They were checked with Python 3.13's html.parser as a structural tree, and with the site build. No stylesheet, font, or image is fetched, and this is not a search-engine or crawler test.

Official sources: MDN <meta> element and the WHATWG HTML Living Standard. Fragments were checked with Python 3.13 html.parser. That parser builds an element tree; it is not a WHATWG conformance checker, and this is not a browser or accessibility test.

HTML tag catalog → · HTML tutorial overview →

head, title, and where metadata belongs

head holds the document's metadata. title is required in a conforming document and should be unique, readable text, not a keyword list. Visible page headings still belong in the body, usually as h1, and are not a substitute for title.

Use meta for charset, viewport, description, robots, and similar name/content pairs. Use link when the metadata is a relationship to a URL, including canonical, stylesheet, icon, and alternate types. If an element's purpose is already covered by title or link, do not invent a parallel meta name for the same job.

charset placement and a zoomable viewport

A meta charset declaration must appear entirely within the first 1024 bytes of the document, as early as possible in head, so the parser can decode the rest of the file, including a non-ASCII title. utf-8 is the encoding to use. A late charset declaration can be ignored.

The viewport meta is a widely supported hint for mobile layout, commonly width=device-width, initial-scale=1. Do not use user-scalable=no or a maximum-scale of 1 to forbid zoom. Those values can lock the page at one scale and harm people who need to enlarge text or UI. This example does not disable zoom.

An early charset, a title, and a viewport that does not forbid zoom

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Document title</title>
  <meta name="description" content="">
</head>

charset comes first in head. The viewport sets a device width and initial scale without disabling zoom. description is only a hint.

AttributeDescription
charsetDeclares the document encoding, which should be utf-8. The element must be fully within the first 1024 bytes of the document.
nameThe metadata name, such as viewport or description. It is not a substitute for title or for link relationships.
contentThe value associated with name. For viewport, width=device-width, initial-scale=1 is a common starting point.
  • The description is a hint for search engines and social tools. It does not guarantee a search-result snippet. No network request is made from this fragment.
html
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Compare two files — DiffCheck</title>
  <meta name="description" content="Compare text, code, and documents in the browser.">
</head>

What this markup means

The charset declaration is the first element in head so decoding can start immediately. The viewport hint uses device width and initial-scale=1 and does not include user-scalable=no or maximum-scale=1. The title is the document title; the description is additional text that a search engine may ignore or rewrite. This is not a live SERP test.

Related: Tag catalog: <meta>, Tag catalog: <head>, Tag catalog: <title>, HTML tutorial: first document

MDN documentation → · WHATWG HTML Standard →

description, canonical, and robots

name="description" can summarize the page, but crawlers may choose another snippet, and visibility in search results is never guaranteed by the presence of the tag.

The canonical URL is expressed with link rel="canonical", not with a meta element. That link names the preferred URL for a document that may be available at more than one address. A relative href is resolved against the document URL; this example uses a same-origin path and does not fetch it.

name="robots" with values such as noindex or nofollow is a hint to cooperating crawlers. It is not access control. It does not authenticate users, hide the resource from a browser, or stop a client that ignores the hint. Keep the file private by authorization or by not publishing it if it must not be read.

canonical is a link, and robots is not access control

<head>
  <link rel="canonical" href="/path/">
  <meta name="robots" content="noindex, nofollow">
</head>

rel=canonical belongs on link, not meta. A robots meta tag does not protect the document from being fetched.

AttributeDescription
rel (link)canonical identifies the preferred URL for this document. This relationship is not expressed with a meta name.
href (link)The preferred URL, often a same-origin path or absolute URL. The example path is not fetched here.
name="robots"A crawler hint such as noindex or nofollow. It is not an access-control mechanism.
  • There is no meta name=canonical in this fragment. There is also no remote stylesheet, font, or image request.
html
<head>
  <meta charset="utf-8">
  <title>Widget compare</title>
  <link rel="canonical" href="/widgets/compare/">
  <meta name="robots" content="noindex, nofollow">
</head>

What this markup means

The preferred URL is declared with link rel="canonical", not with a meta tag. The robots meta tag asks cooperating crawlers not to index or follow links, but it does not authenticate anyone or prevent a direct request for the document. charset is still first, and the relative canonical href is not fetched from this page.

Related: Tag catalog: <link>, Tag catalog: <meta>, Tag catalog: <title>, HTML tutorial: first document

MDN documentation → · WHATWG HTML Standard →