HTML <meta> Tag

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The <meta> element represents document metadata that other head tags cannot cover — unlike <title>, <link>, or <style>.

Common jobs: declare charset, set the viewport, and publish a description with name + content. Place meta tags in <head>.

Baseline · Widely available.

Not deprecated. Core meta support has been stable since about July 2015. Some name values (and media on theme-color) have uneven support.

Warning.

Avoid http-equiv="refresh" for timed redirects — it harms accessibility. Prefer a server HTTP redirect or a clear user-chosen link.

HTML Syntax

syntax.html
<meta charset=" utf-8">

Void element: start tag only, no end tag, no children. Use one of charset, name+content, or http-equiv+content (do not mix those modes arbitrarily).

Attributes

Attributes on <meta> (plus global attributes):

AttributeDescriptionTry it
charsetDocument character encoding — must be utf-8 in HTML5Try it
nameMetadata name (description, viewport, author, …)Try it
contentValue paired with name or http-equivTry it
http-equivPragma directive (HTTP-header equivalent)Use carefully
mediaMedia query for name="theme-color" onlytheme-color

Global Attributes

The <meta> tag also supports the Global Attributes in HTML. Do not combine itemprop with name, http-equiv, or charset on the same element.

Live Preview

Edit a meta description and see a simplified search-style snippet. Meta tags are not visible on the page itself.

Simulated result of <meta name="description" content="…"> — engines may rewrite snippets.

Search-style preview

HTML meta Tag (Document Metadata) | CodeToFun

https://www.codetofun.com/html/tags/meta

Learn HTML meta tags: charset, viewport, and description.

<meta name="description" content="Learn HTML meta tags: charset, viewport, and description.">

HTML Examples

Essential head metadata: encoding, viewport, and description.

Example 1 — Character Encoding

Declare UTF-8 early in <head> so browsers decode the page correctly.

HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>My page</title>
</head>
<body>
  <p>Hello</p>
</body>
</html>
Try It Yourself

How It Works

  1. Add <meta charset="utf-8"> near the top of <head>.
  2. Keep it within the first 1024 bytes of the file so parsers see it early.
  3. Use only UTF-8 for HTML5 documents.
  4. Visitors never “see” the tag — it guides the browser’s decoder.

Example 2 — Viewport for Mobile

Tell mobile browsers to match the layout width to the device.

HTML
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Responsive page</title>
</head>
Try It Yourself

How It Works

  1. Set name="viewport" for viewport metadata.
  2. width=device-width matches CSS pixels to the device width.
  3. initial-scale=1 starts at 100% zoom.
  4. Without it, many phones shrink a “desktop-width” page and force pinch-zoom.

Example 3 — Meta Description

Provide a short summary search engines may show under your title.

HTML
<head>
  <meta charset="utf-8">
  <title>HTML meta Tag | CodeToFun</title>
  <meta
    name="description"
    content="Learn HTML meta tags: charset, viewport, and description."
  >
</head>
Try It Yourself

How It Works

  1. Use name="description" with a concise content summary.
  2. Keep it accurate — engines may ignore or rewrite poor snippets.
  3. Pair with a clear <title> for the result headline.
  4. It is not a ranking switch — it mainly influences how the result can look.

Edge Cases & Pitfalls

Most meta mistakes are placement, outdated SEO myths, or harmful redirects.

placement

Keep meta in <head>

Document metadata belongs with <head>. Put charset first among meta tags.

keywords

keywords is mostly ignored

Major search engines do not use meta keywords for ranking. Focus on real content and a good description.

a11y

Skip timed refresh redirects

http-equiv="refresh" can move users without consent. Prefer HTTP redirects or explicit links.

modes

One job per meta element

Use either charset, or name+content, or http-equiv+content — not conflicting combinations.

viewport

Do not disable zoom casually

Avoid locking user-scalable=no / extreme maximum-scale — it hurts accessibility.

Browser Support

The <meta> element is Baseline · Widely available. Charset, viewport, and description are broadly supported; some named metadata values vary by browser.

✓ Baseline · Widely available

<meta>

Supported in modern Chrome, Firefox, Safari, Edge, and Opera. Metadata is not rendered as visible page content.

100% Modern browser coverage
Google Chrome Yes
Supported
Mozilla Firefox Yes
Supported
Apple Safari Yes
Supported
Microsoft Edge Yes
Supported
Opera Yes
Supported
Internet Explorer Yes · EOL
Supported
<meta> Widely available

Bottom line: Every HTML page should include charset and a viewport meta tag; add description when you want a clear search snippet.

Key Takeaways

  • Role: <meta> stores document metadata inside <head>.
  • Essentials: charset="utf-8", viewport, and a clear description.
  • Pairs: name/http-equiv + content supply name–value metadata.
  • Avoid: refresh redirects and relying on meta keywords for SEO.

One line: Start every page with UTF-8 + viewport meta, then add accurate descriptions when needed.

Default CSS Settings

meta is metadata — not rendered as visible content. User agents typically treat it as:

default.css
meta {
  display: none;
}

You do not style meta for layout. Effects come from how browsers and crawlers read the attributes.

Frequently Asked Questions

The meta element provides document metadata that other head elements cannot express — character encoding, viewport hints, descriptions, and name/content pairs for browsers and crawlers.
Put meta inside the head. Place charset as early as possible (within the first 1024 bytes). Viewport and description also belong in head.
HTML5 documents must use UTF-8. Use <meta charset="utf-8">. Other encodings are not valid for HTML documents.
name="viewport" with a content value like width=device-width, initial-scale=1 tells mobile browsers how to size the layout viewport for responsive pages.
It does not directly rank pages, but search engines often use it as the snippet under your title. Write a clear, accurate summary.
Avoid it. Timed redirects hurt accessibility and usability. Prefer an HTTP redirect from the server, or a normal link users choose.

Next: meter

Show a scalar measurement within a known range.

meter tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful