Container for metadata elements. All meta tags must be placed inside the head element. Learn more →
<meta> ElementThe meta element provides structured metadata about the HTML document. This metadata is not displayed on the page but is used by browsers, search engines, social media platforms, and other web services to understand and present your content.
<meta charset="UTF-8"><meta name="name" content="value"><meta http-equiv="directive" content="value"><meta property="property" content="value">Meta elements are void elements (self-closing) and must be placed inside the <head> element. They use different attribute combinations to define different types of metadata.
| Attribute | Description | Example Values |
|---|---|---|
charset | Character encoding for the document | UTF-8 (recommended) |
name | Name of the metadata property | description, keywords, author, viewport |
content | Value of the metadata property | Varies by name or http-equiv |
http-equiv | HTTP header directive | refresh, content-type, content-security-policy |
property | Property for Open Graph/RDFa | og:title, og:image, og:description |
Different meta tags use different attribute combinations:
Charset declaration: <meta charset="UTF-8">
Named metadata: <meta name="..." content="...">
HTTP equivalents: <meta http-equiv="..." content="...">
Open Graph/RDFa: <meta property="..." content="...">
Always declare UTF-8 encoding as the first element in <head>:
Essential for mobile-friendly websites:
Common viewport values:
Basic responsive: width=device-width, initial-scale=1.0
Prevent zoom: width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no (not recommended for accessibility)
Minimal UI on iOS: width=device-width, initial-scale=1.0, minimal-ui
The description appears in search engine results:
<meta name="description" content="Learn HTML meta tags with comprehensive examples covering SEO, social media, and responsive design. Beginner-friendly guide with code samples."><meta name="keywords" content="HTML, meta tags, SEO, web development"><meta name="author" content="Jane Doe"><meta name="creator" content="Jane Doe"><meta name="publisher" content="Example Publishing">Control how search engines crawl and index your page:
<!-- Allow indexing and following links (default) --><meta name="robots" content="index, follow">
<!-- Prevent indexing but allow following links --><meta name="robots" content="noindex, follow">
<!-- Prevent indexing and following links --><meta name="robots" content="noindex, nofollow">
<!-- Prevent showing cached version --><meta name="robots" content="noarchive">
<!-- Prevent showing description from DMOZ/ODP --><meta name="robots" content="noodp">
<!-- Prevent image indexing --><meta name="robots" content="noimageindex">
<!-- Combined directives --><meta name="robots" content="noindex, nofollow, noarchive">Target specific search engines:
<meta name="googlebot" content="noindex"><meta name="bingbot" content="nofollow">Open Graph tags control how your content appears when shared on Facebook, LinkedIn, and other platforms:
Essential Open Graph properties:
og:title — Title of the content (appears as the main headline)
og:description — Brief description (appears below the title)
og:image — Image URL (displays as thumbnail, recommended 1200x630px)
og:url — Canonical URL of the page
og:type — Type of content (website, article, video.movie, etc.)
og:site_name — Name of the overall site
Additional properties for articles:
<meta property="article:published_time" content="2024-01-15T09:00:00Z"><meta property="article:author" content="https://example.com/authors/jane"><meta property="article:section" content="Technology"><meta property="article:tag" content="HTML">Twitter uses its own meta tags (though it falls back to Open Graph):
<!-- Summary card --><meta name="twitter:card" content="summary"><meta name="twitter:site" content="@username"><meta name="twitter:title" content="Amazing Web Development Guide"><meta name="twitter:description" content="Master HTML with our comprehensive guide"><meta name="twitter:image" content="https://example.com/twitter-image.jpg">
<!-- Large image card --><meta name="twitter:card" content="summary_large_image"><meta name="twitter:site" content="@username"><meta name="twitter:creator" content="@author"><meta name="twitter:title" content="Amazing Web Development Guide"><meta name="twitter:description" content="Master HTML with our comprehensive guide"><meta name="twitter:image" content="https://example.com/large-image.jpg">Card types:
summary — Title, description, and small square image
summary_large_image — Similar to summary but with a large prominent image
app — Mobile app promotion card
player — Video/audio player card
Set the browser UI color on mobile devices:
Support media queries for light/dark mode:
<meta name="theme-color" content="#4f46e5" media="(prefers-color-scheme: light)"><meta name="theme-color" content="#1e1b4b" media="(prefers-color-scheme: dark)">The http-equiv attribute provides HTTP header directives:
Refresh/Redirect:
<!-- Refresh page every 30 seconds --><meta http-equiv="refresh" content="30">
<!-- Redirect after 5 seconds --><meta http-equiv="refresh" content="5; url=https://example.com/new-page">Content Type (Legacy):
<!-- Old way (use charset attribute instead) --><meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- Modern way --><meta charset="UTF-8">Content Security Policy:
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline';">X-UA-Compatible (IE):
<!-- Force IE to use latest rendering engine --><meta http-equiv="X-UA-Compatible" content="IE=edge">Here’s a comprehensive example combining all major meta tags:
<!DOCTYPE html><html lang="en"><head> <!-- Character encoding (must be first) --> <meta charset="UTF-8">
<!-- Viewport for responsive design --> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- SEO basics --> <meta name="description" content="Comprehensive guide to HTML meta tags covering SEO, Open Graph, Twitter Cards, and responsive design. Expert tips for web developers."> <meta name="keywords" content="HTML, meta tags, SEO, Open Graph, web development"> <meta name="author" content="Jane Doe"> <meta name="robots" content="index, follow">
<!-- Open Graph for Facebook, LinkedIn, etc. --> <meta property="og:title" content="Complete HTML Meta Tags Guide"> <meta property="og:description" content="Comprehensive guide to HTML meta tags covering SEO, Open Graph, Twitter Cards, and responsive design."> <meta property="og:image" content="https://example.com/images/meta-guide-social.jpg"> <meta property="og:url" content="https://example.com/guides/html-meta-tags"> <meta property="og:type" content="article"> <meta property="og:site_name" content="Web Dev Academy"> <meta property="article:published_time" content="2024-12-11T10:00:00Z"> <meta property="article:author" content="Jane Doe">
<!-- Twitter Cards --> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:site" content="@webdevacademy"> <meta name="twitter:creator" content="@janedoe"> <meta name="twitter:title" content="Complete HTML Meta Tags Guide"> <meta name="twitter:description" content="Comprehensive guide to HTML meta tags covering SEO, Open Graph, Twitter Cards, and responsive design."> <meta name="twitter:image" content="https://example.com/images/meta-guide-twitter.jpg">
<!-- Mobile browser theme --> <meta name="theme-color" content="#4f46e5">
<!-- Page title --> <title>Complete HTML Meta Tags Guide | Web Dev Academy</title></head><body> <h1>Complete HTML Meta Tags Guide</h1> <p>Your content here...</p></body></html>Meta Description: Appears as the snippet text in search results below the page title. While not a direct ranking factor, a compelling description improves click-through rates, which can indirectly boost rankings.
Meta Robots: Directly controls whether search engines index and crawl your page. Use noindex for duplicate content, admin pages, or private sections.
Meta Keywords: Ignored by Google and most search engines since the early 2000s due to spam. Historical artifact with no modern SEO value.
Viewport: Required for mobile-friendliness, which is a ranking factor. Pages without proper viewport settings may be penalized in mobile search results.
Open Graph and Twitter Cards: Not ranking factors but improve social sharing, which can drive traffic and indirect SEO benefits.
<meta name="description" content="Learn Python programming with 50+ interactive tutorials. Master data structures, algorithms, and web development. Start your coding journey today.">Clear value proposition, includes key topics, compelling call-to-action, and stays under 160 characters.
<meta name="description" content="Python tutorials. Learn Python. Best Python course. Python programming. Python lessons. Free Python.">Keyword stuffing, repetitive, no clear value, reads poorly, and may be ignored by search engines.
Validate how your meta tags appear:
Google Search Results: Use Google Search Console to see how Google renders your pages.
Facebook Sharing: Test with Facebook Sharing Debugger.
Twitter Cards: Validate with Twitter Card Validator.
Open Graph: Use OpenGraph.xyz to preview all social platforms.
<meta name="viewport" content="width=device-width, initial-scale=1.0">Allows users to zoom and pan. Accessible to users with low vision who need magnification.
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">Disables zoom, which violates WCAG 2.1 Level AA accessibility guidelines. Users with low vision cannot magnify content.
Automatic page refreshes can be disorienting and problematic:
Screen reader interruption: Content being read is suddenly replaced, losing the user’s position.
Seizure risk: Unexpected content changes can trigger seizures in photosensitive users.
Lost form data: Users filling out forms may lose their input when the page refreshes.
If refresh is absolutely necessary, provide adequate warning and allow users to disable it:
<!-- Give users 120 seconds to read/disable --><meta http-equiv="refresh" content="120; url=https://example.com/updated">Better approach with JavaScript that can be paused:
<script> // Allow user control over refresh let autoRefresh = true; setTimeout(() => { if (autoRefresh) window.location.href = 'https://example.com/updated'; }, 120000);</script><button onclick="autoRefresh = false">Disable Auto-Refresh</button>Always combine <meta charset> with the lang attribute on the <html> element:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Accessible Page</title></head>This combination ensures screen readers pronounce content correctly and browsers render characters properly.
| Browser | Version | Notes |
|---|---|---|
| Chrome | 1+ | Full support including viewport, theme-color |
| Firefox | 1+ | Full support |
| Safari | 1+ | Full support, theme-color since Safari 15 |
| Edge | 12+ | Full support |
| IE | 3+ | Basic support, limited Open Graph support |
Charset: Universally supported since HTML 4.
Viewport: Supported by all mobile browsers since iOS Safari 3 and Android 2.1.
Theme-color: Chrome 39+, Safari 15+, Edge 79+. Ignored by browsers that don’t support it.
Open Graph: Not browser-specific, consumed by social media platforms.
HTTP-equiv refresh: Widely supported but discouraged for accessibility and SEO.
Container for metadata elements. All meta tags must be placed inside the head element. Learn more →
Defines the document title shown in browser tabs and search results. Required in every HTML document. Learn more →
Links external resources like stylesheets, icons, and canonical URLs. Another critical metadata element. Learn more →
Specifies base URL for relative links. Affects how URLs in the document are resolved. Learn more →