<meta> Tag in HTML

Quick facts

CategoryMetadata content
Content modelEmpty — it’s a void element
Tag omissionVoid element — no end tag, ever
Permitted parentsA <head> element (meta with itemprop can also appear in the body)
DOM interfaceHTMLMetaElement

Syntax

<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content="A one-sentence summary of the page.">

Live example

Edit the code below and watch the preview update instantly.

index.html
Preview

Attributes

AttributeDescription
charsetThe page’s character encoding — always UTF-8, placed first in the head
nameWhat kind of information this is, e.g. description, viewport, robots, theme-color, author
contentThe value that goes with name, http-equiv or property
http-equivActs like an HTTP header, e.g. content-security-policy or refresh
mediaApplies a theme-color only for a media query, e.g. dark mode
propertyNot part of HTML itself: used by Open Graph social tags such as og:title and og:image

Common examples

The essential meta tags

Every page should start with these three: the character set, the mobile viewport and a unique description.

<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content="Free online HTML editor with live preview.">

Social sharing previews (Open Graph)

These tags control the title, text and image shown when someone shares your page on Facebook, LinkedIn, X or messaging apps.

<meta property="og:title" content="Free HTML Editor"> <meta property="og:description" content="Write HTML and see it live."> <meta property="og:image" content="https://example.com/share.png"> <meta name="twitter:card" content="summary_large_image">

Keep a page out of search results

A noindex robots tag tells search engines not to list the page — useful for thank-you pages or internal search results.

<meta name="robots" content="noindex, follow">

Browser color in light and dark mode

The theme-color tag tints the browser bar on phones, and the media attribute lets you choose a color for each mode.

<meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)"> <meta name="theme-color" content="#0a0a14" media="(prefers-color-scheme: dark)">

meta robots vs robots.txt

They control different things. A robots.txt file tells search engines which addresses they may crawl (visit). A <meta name="robots" content="noindex"> tag tells them not to index (list) a page they have visited.

That difference matters: a page blocked in robots.txt can still appear in Google if other sites link to it, because Google never sees its noindex tag. To keep a page out of search results, allow crawling and use the meta robots tag — don’t combine noindex with a robots.txt block.

meta robotsrobots.txt
ControlsIndexing (listing)Crawling (visiting)
Applies toOne pageWhole site or folders
Keeps a page out of GoogleYes (noindex)Not reliably

Common mistakes to avoid

  • The same description on every page. Each page needs its own; duplicates give search engines nothing useful to show.
  • Blocking zoom. maximum-scale=1 or user-scalable=no in the viewport stops people with low vision from zooming in.
  • A missing or late charset. <meta charset="UTF-8"> should be the very first thing in the head, or accented letters and symbols can break.
  • Stuffing keywords. The keywords meta tag is ignored by Google, and keyword-stuffed descriptions put people off clicking.

Accessibility & SEO tips

  • Write descriptions of roughly 120–158 characters that say what the page offers and why someone should click.
  • Use an Open Graph image of about 1200 × 630 pixels so shared links look good everywhere.
  • Never disable zooming in the viewport tag — it’s one of the most common accessibility failures on mobile sites.

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

Does the meta keywords tag help SEO?
No. Google has ignored <meta name="keywords"> for many years. Spend the effort on a good <title> and <meta name="description"> instead.
Why do I need the viewport meta tag?
Without <meta name="viewport" content="width=device-width, initial-scale=1">, phones show the page zoomed out as if on a desktop screen. With it, your responsive CSS works as intended.
Does Google always use my meta description?
Not always. Google often shows your description in search results, but it may write its own snippet from the page text if that better matches the search. A clear, specific description of about 120–158 characters gives you the best chance.
How long should a meta description be?
About 120–158 characters. Google cuts longer descriptions off around that length on desktop, so put the most important words first.
What are Open Graph tags?
Meta tags starting with og: (og:title, og:description, og:image) that control how your page looks when shared on social networks and messaging apps. Without them, those sites guess, often badly.
How do I stop Google from indexing a page?
Add <meta name="robots" content="noindex"> to the page and make sure it isn't blocked in robots.txt, so Google can visit it and see the instruction. On WordPress, SEO plugins such as Yoast have a setting for this.