Meta Tags Reference

Complete guide to HTML meta tags for SEO, social media, and browser behavior

What are Meta Tags?

Meta tags are HTML elements that provide metadata about your web page. They are placed in the <head> section and are not visible to users, but they provide important information to browsers, search engines, and social media platforms.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="Learn HTML with our comprehensive tutorial"> <title>HTML Tutorial</title> </head> <body> <!-- Page content --> </body> </html>

Important: Meta tags are crucial for SEO, social media sharing, and proper browser behavior. They should be included in every HTML document.

Essential Meta Tags

Basic Meta Tags

charset
Specifies the character encoding for the document
<meta charset="UTF-8">
viewport
Controls the page's dimensions and scaling for mobile devices
<meta name="viewport" content="width=device-width, initial-scale=1.0">
description
Provides a brief description of the page content (150-160 characters)
<meta name="description" content="Learn HTML basics with examples and tutorials">
keywords
Lists relevant keywords (less important for modern SEO)
<meta name="keywords" content="HTML, tutorial, web development">

SEO Meta Tags

robots
Controls how search engines crawl and index the page
<meta name="robots" content="index, follow">
author
Specifies the author of the document
<meta name="author" content="John Doe">
canonical
Prevents duplicate content issues by specifying the preferred URL
<link rel="canonical" href="https://example.com/page">
language
Specifies the language of the document content
<meta http-equiv="content-language" content="en-US">

Social Media Meta Tags

Open Graph (Facebook)

og:title
Title that appears when shared on social media
<meta property="og:title" content="HTML Tutorial - Learn Web Development">
og:description
Description for social media sharing
<meta property="og:description" content="Complete HTML tutorial for beginners">
og:image
Image that appears when shared (1200x630px recommended)
<meta property="og:image" content="https://example.com/image.jpg">
og:url
Canonical URL of the page
<meta property="og:url" content="https://example.com/html-tutorial">

Twitter Cards

twitter:card
Type of Twitter card (summary, summary_large_image, etc.)
<meta name="twitter:card" content="summary_large_image">
twitter:title
Title for Twitter sharing
<meta name="twitter:title" content="HTML Tutorial">
twitter:description
Description for Twitter sharing
<meta name="twitter:description" content="Learn HTML basics">
twitter:image
Image for Twitter sharing
<meta name="twitter:image" content="https://example.com/image.jpg">

Browser Behavior Meta Tags

Mobile & Performance

theme-color
Sets the browser theme color on mobile devices
<meta name="theme-color" content="#3b82f6">
apple-mobile-web-app-capable
Enables full-screen mode on iOS devices
<meta name="apple-mobile-web-app-capable" content="yes">
format-detection
Controls automatic detection of phone numbers, emails, etc.
<meta name="format-detection" content="telephone=no">
preload
Preloads critical resources for better performance
<link rel="preload" href="font.woff2" as="font" type="font/woff2">

Security & Privacy

referrer
Controls how much referrer information is sent
<meta name="referrer" content="strict-origin-when-cross-origin">
content-security-policy
Defines security policies for content loading
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">
x-ua-compatible
Forces Internet Explorer to use latest rendering engine
<meta http-equiv="X-UA-Compatible" content="IE=edge">

Complete Meta Tags Template

Best Practice: Use this template as a starting point for your HTML documents. Customize the content values for each page.

<!DOCTYPE html> <html lang="en"> <head> <!-- Basic Meta Tags --> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="Your page description here (150-160 characters)"> <meta name="keywords" content="keyword1, keyword2, keyword3"> <meta name="author" content="Your Name"> <!-- SEO Meta Tags --> <meta name="robots" content="index, follow"> <link rel="canonical" href="https://yoursite.com/current-page"> <!-- Open Graph Meta Tags --> <meta property="og:title" content="Your Page Title"> <meta property="og:description" content="Your page description"> <meta property="og:image" content="https://yoursite.com/image.jpg"> <meta property="og:url" content="https://yoursite.com/current-page"> <meta property="og:type" content="website"> <!-- Twitter Card Meta Tags --> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:title" content="Your Page Title"> <meta name="twitter:description" content="Your page description"> <meta name="twitter:image" content="https://yoursite.com/image.jpg"> <!-- Browser Behavior --> <meta name="theme-color" content="#3b82f6"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Your Page Title</title> </head> <body> <!-- Your page content --> </body> </html>

Meta Tags Best Practices

Important Guidelines:

  • Keep descriptions between 150-160 characters
  • Use unique meta tags for each page
  • Include Open Graph tags for social media
  • Always include viewport meta tag for mobile
  • Use UTF-8 character encoding

Common Mistakes to Avoid

  • Duplicate meta descriptions across pages
  • Missing or incorrect viewport settings
  • Too long or too short descriptions
  • Missing Open Graph images
  • Incorrect character encoding

Test Your Knowledge

1. What is the recommended length for meta descriptions?

50-100 characters
150-160 characters
200-250 characters
No limit

2. Which meta tag is essential for mobile responsiveness?

charset
viewport
description
keywords