Meta tag

On this page 7

A meta tag is an HTML element placed in the document head that provides metadata about a page: information for browsers, search engines, social platforms and other software rather than content for the reader. In HTML, meta tags declare the character encoding, control the viewport on mobile devices, supply a page description and give instructions to crawlers, among other uses.

The element is written as meta and is a void element: it has attributes but no content and no closing tag. Its meaning comes entirely from which attributes it carries, typically a name, http-equiv, charset or property attribute paired with a content value.

How meta tags are structured

Each meta tag follows one of a few attribute patterns, and the pattern tells the consuming software how to interpret it. The HTML specification defines the core patterns, while other vocabularies, such as social sharing protocols, add their own names on top of them.

FormExample attributesPurpose
charsetcharset set to utf-8Declares the character encoding of the document
name and contentname set to description, content with the summaryNamed metadata for browsers and crawlers
http-equiv and contenthttp-equiv set to content-security-policySimulates an HTTP response header
property and contentproperty set to og:titleSocial sharing metadata in the Open Graph vocabulary
itempropitemprop with a valueMicrodata properties inside structured data
Main forms of the meta element

The charset declaration has a strict rule: it must appear within the first 1,024 bytes of the document, so it is normally the first element in the head. If it appears later, the browser may already have guessed an encoding and render characters incorrectly.

The most important meta tags

Only a handful of meta tags matter on almost every page. The others are specialized and should be added when a concrete consumer actually reads them, not out of habit.

Meta tagTypical valueConsumerEffect
charsetutf-8BrowserCorrect display of all characters
viewportwidth set to device-width, initial-scale 1Mobile browsersResponsive layout instead of a zoomed-out desktop page
descriptionOne summary sentence, roughly 120 to 160 charactersSearch enginesOften used as the result snippet
robotsnoindex, nofollow and similar directivesCrawlersControls indexing and link following
theme-colorA color valueMobile browsersTints the browser interface
referrerA referrer policy such as strict-originBrowserLimits referrer data sent with requests
Commonly used meta tags

The keywords meta tag is a frequent leftover from early web practice. Major search engines ignore it for ranking, because it was widely abused, so maintaining it adds work without benefit.

Meta tags and search or social visibility

Meta tags influence how a page is represented elsewhere, not how it ranks directly. A meta description does not raise rankings, but a precise one can make the search result snippet more relevant and attractive. Search engines may still rewrite the snippet when they find page text that better matches a query.

The robots meta tag is the main exception with direct effect. A noindex directive keeps a page out of search results, but only if crawlers can fetch the page. Blocking the same page in robots.txt prevents the crawler from ever seeing the noindex directive, which is a common and counterintuitive mistake.

Social platforms read Open Graph and similar tags to build link previews with a title, description and image. These tags use the property attribute and are defined by the platforms rather than the HTML specification, which is why their names contain a prefix such as og.

Meta tags compared with other head and HTML features

Meta tags are one of several ways to attach information to a document. Choosing the right mechanism avoids duplication and conflicts with neighboring HTML features.

MechanismLocationBest forRelation to meta tags
Meta tagDocument headPage-level metadataSimple name and value pairs
Title elementDocument headPage title in tabs and resultsNot a meta tag, but often confused with one
Link elementDocument headCanonical URL, icons, stylesheetsPoints to resources rather than stating values
HTTP headersServer responseSecurity and caching policyUsually stronger than http-equiv equivalents
Structured dataScript block or attributesDetailed entities such as products and eventsRicher than meta tags for search features
Meta tags and related mechanisms

For security and caching, real HTTP headers are preferred over http-equiv meta tags. Some directives, such as frame-ancestors in a content security policy, are not honored at all when delivered through a meta tag.

Common mistakes with meta tags

Errors in meta tags are often invisible during development because the page still looks correct. Their effects show up later, in search results, link previews or on mobile devices.

SymptomLikely causeFix
Garbled special charactersMissing or late charset declarationPlace the utf-8 declaration first in the head
Tiny text on phonesMissing viewport tagAdd the viewport tag with device-width
Pages missing from searchLeftover noindex from a staging setupRemove noindex before launch
Same snippet for every pageDuplicate meta descriptions from a templateWrite a unique description per page
Blank or wrong link previewsMissing or relative Open Graph image URLProvide an absolute image URL
Meta tag problems and fixes

A further mistake is disabling zoom with maximum-scale or user-scalable settings in the viewport tag. This prevents users with low vision from enlarging text and conflicts with accessibility requirements, so modern practice leaves zoom enabled.

In everyday language

A meta tag is a hidden note at the top of a web page. Visitors never see it on the page itself. Browsers, search engines and social networks read it to learn about the page.

One note might say which alphabet the page uses. Another tells a phone to fit the page to its screen. Another gives a short summary for search results. These small notes shape how a page looks and how it is described everywhere else online.

Seen in the real world

A small online bookstore launches a redesigned website built on a staging server. Two weeks after launch, the owner notices that new book pages do not appear in search results and that shared links on social networks show no image.

A developer inspects the page head and finds two problems. The template still contains a robots meta tag with noindex, copied from the staging configuration, and the Open Graph image tag uses a relative path that social platforms cannot resolve. The developer removes the noindex directive, switches the image to an absolute URL and adds a unique meta description generated from each book’s summary.

Within days, crawlers revisit the pages and the book pages begin to appear in search results. Shared links now display the cover image, title and description, and the bookstore adds a launch checklist that includes reviewing all meta tags.