Tutorials HTML Meta Tags & SEO
Ch 18 / 40
Chapter 18 Beginner 10 min read HTML

HTML Meta Tags & SEO Elements

Meta tags live in the <head> and are invisible to users — but they are the most important part of every page for search engines, social media, and browsers. They tell Google what your page is about, control how it looks when shared on social media, instruct crawlers whether to index or follow, and set the character encoding. In this chapter you'll master every <meta> tag, Open Graph, Twitter Cards, the canonical URL, robots directives, and structured data with JSON-LD schema.

What you'll learn
Essential meta tags — charset, viewport, description
SEO meta tags — title, description character limits
Open Graph tags for Facebook & LinkedIn sharing
Twitter Card meta tags for rich tweet previews
Robots meta, canonical URL, noindex, nofollow
Structured data — JSON-LD schema for rich results

What are Meta Tags?

A <meta> element is a self-closing tag that lives inside <head> and provides metadata about the HTML document — data that describes the page rather than displaying on it. Meta tags have no closing tag. They use either a name/content pair or a property/content pair (for Open Graph), or standalone attributes like charset.

HTML — meta tag syntax patterns
<!-- Pattern 1: charset (standalone attribute) -->
<meta charset="UTF-8">

<!-- Pattern 2: name / content pair -->
<meta name="description"
      content="Learn HTML at K2infocom Vadodara.">

<!-- Pattern 3: property / content pair (Open Graph) -->
<meta property="og:title"
      content="HTML Tutorial — K2infocom">

<!-- Pattern 4: http-equiv (browser instructions) -->
<meta http-equiv="X-UA-Compatible"
      content="IE=edge">
Essential Meta Tags
charset, viewport, theme-color — required on every page. Without these pages render incorrectly on mobile and with broken characters.
SEO Meta Tags
description, keywords, author — read by Google for the search result snippet. Description directly affects click-through rate.
Open Graph Tags
og:title, og:description, og:image, og:url — control how your page looks when shared on Facebook, LinkedIn, WhatsApp.
Robots Directives
robots, googlebot, noindex, nofollow — tell search engine crawlers what to do with the page: index it, skip it, or not follow its links.
HTTP-Equiv Tags
http-equiv simulates HTTP headers — browser compatibility, page refresh/redirect, and cache control instructions sent at the HTML level.

Essential Meta Tags — Required on Every Page

These three meta tags should be in the <head> of every HTML page you build — without exception:

charset="UTF-8"
Declares the character encoding of the HTML document. UTF-8 supports every character in every language — Latin, Devanagari, Chinese, Arabic, emoji, and special symbols. Without it, browsers make a best guess and often display broken characters (mojibake). Must be the first tag in <head> — before the <title>.
name="viewport"
Controls how the page is displayed on mobile devices. Without it, mobile browsers render the page at desktop width (980px) and scale it down — making text tiny and unreadable. width=device-width, initial-scale=1.0 makes the page use the device's actual screen width and starts at 100% zoom. Required for all responsive websites.
name="theme-color"
Sets the browser chrome (address bar, task switcher) colour on Android Chrome and other supporting browsers. Enhances the branded feel of your site when saved to a home screen or viewed as a PWA. The value is a hex, RGB, or named colour.
HTML — Essential meta tags
<head>
  <!-- 1. charset MUST be first inside <head> -->
  <meta charset="UTF-8">

  <!-- 2. Viewport — essential for responsive design -->
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0">

  <!-- 3. Theme colour (Android browser chrome) -->
  <meta name="theme-color" content="#e44d26">

  <!-- 4. IE compatibility (older browsers) -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <!-- 5. Title (not a meta tag but lives in <head>) -->
  <title>HTML Tutorial — Chapter 18 | K2infocom</title>
</head>

SEO Meta Tags — Title & Description

The <title> and meta description are the two most impactful on-page SEO elements. They directly control your Google search result snippet — the clickable blue text and the grey description below it.

Google Search Result Preview
https://k2infocom.com › tutorial › html › html-meta-seo
HTML Meta Tags & SEO Elements — Complete Guide | K2infocom
Learn all HTML meta tags — charset, viewport, description, Open Graph, Twitter Cards, canonical, and JSON-LD structured data. Free tutorial by K2infocom, Vadodara.
Title: 50–60 characters (Google truncates beyond ~580px width). Description: 150–160 characters — longer text is cut with "…". Both should include your primary keyword naturally.
HTML — SEO title, description, keywords, author
<!-- Page title — appears in browser tab + Google results -->
<title>HTML Tutorial — Chapter 18 | K2infocom Vadodara</title>

<!-- Meta description — Google search snippet (150-160 chars) -->
<meta name="description"
      content="Learn all HTML meta tags — charset, viewport,
      Open Graph, Twitter Cards, canonical URL, robots
      directives and JSON-LD schema. Free tutorial by K2infocom.">

<!-- Keywords — low Google weight but used by some search engines -->
<meta name="keywords"
      content="HTML meta tags, SEO, Open Graph, Twitter Cards,
      canonical, robots, JSON-LD, schema, K2infocom">

<!-- Author -->
<meta name="author" content="K2infocom">

<!-- Robots — allow indexing and link following -->
<meta name="robots" content="index, follow">
Title Formula That Works
The proven pattern: Primary Keyword — Secondary Keyword | Brand Name. Example: HTML Meta Tags Explained — SEO Guide | K2infocom. Put the keyword first — Google gives more weight to keywords near the beginning of the title. Keep it under 60 characters. Every page must have a unique title — duplicate titles hurt SEO.

Open Graph Meta Tags — Social Media Sharing

When someone shares your URL on Facebook, LinkedIn, or WhatsApp, these platforms scrape the page and display a rich preview card. Open Graph (developed by Facebook) lets you control exactly what that card shows — title, description, and image. Without OG tags, social platforms pick content randomly from your page, often with terrible results.

HTML — Complete Open Graph tags
<!-- Open Graph — essential 4 (required for all pages) -->
<meta property="og:title"
      content="HTML Meta Tags & SEO — Complete Guide | K2infocom">

<meta property="og:description"
      content="Master charset, viewport, Open Graph, Twitter Cards,
      canonical URL, robots directives and JSON-LD schema.">

<meta property="og:image"
      content="https://k2infocom.com/images/html-course-og.jpg">
<!-- Image: minimum 1200×630px, use absolute URL -->

<meta property="og:url"
      content="https://k2infocom.com/tutorial/html/html-meta-seo.html">

<!-- Open Graph — additional recommended tags -->
<meta property="og:type"      content="article">
<meta property="og:site_name"  content="K2infocom">
<meta property="og:locale"    content="en_IN">
<meta property="og:image:width"  content="1200">
<meta property="og:image:height" content="630">
OG Image Requirements
The OG image must be at least 1200 × 630 pixels (1.91:1 ratio) for Facebook and LinkedIn. Use an absolute URL (not relative) — social scrapers fetch the image directly and cannot resolve relative paths. Recommended format: JPEG for photos (smaller file size), PNG for text-heavy graphics. Cache can be cleared with Facebook's Sharing Debugger tool.

Twitter Card Meta Tags

Twitter (X) uses its own separate set of meta tags — though it falls back to Open Graph if Twitter tags are absent. The most important is twitter:card which selects the card type.

twitter:card = "summary_large_image"
Shows a large hero image above the title and description — the most visually impactful card type. Best for articles, tutorials, and product pages. Use this as your default for blog and course content.
twitter:card = "summary"
Shows a small square thumbnail to the left of the text — compact card for link previews. Use for generic pages where the image is not the focus.
twitter:card = "player"
Embeds an inline video or audio player directly in the tweet card. Requires Twitter app approval. Used by video platforms like YouTube and Vimeo.
HTML — Complete Twitter Card tags
<!-- Twitter Card — summary_large_image (recommended) -->
<meta name="twitter:card"
      content="summary_large_image">

<meta name="twitter:title"
      content="HTML Meta Tags & SEO — Complete Guide">

<meta name="twitter:description"
      content="Master charset, viewport, OG, Twitter Cards,
      canonical URL, robots and JSON-LD schema.">

<meta name="twitter:image"
      content="https://k2infocom.com/images/html-course-og.jpg">
<!-- Twitter image: minimum 300×157px, max 5MB -->

<meta name="twitter:site"    content="@k2infocom">
<meta name="twitter:creator" content="@k2infocom">

Canonical URL & Robots Directives

Two critical elements for controlling how search engines crawl and index your site:

<link rel="canonical" href="...">
The canonical tag tells Google the preferred version of a page when duplicate or near-duplicate URLs exist. For example, https://k2infocom.com/tutorial/html/ and https://k2infocom.com/tutorial/html/?ref=blog are the same page. The canonical tag points Google to the authoritative URL — consolidating link equity and preventing duplicate content penalties. Always set a canonical on every page pointing to itself.
meta name="robots"
Instructs search engine crawlers how to handle the page. The value is a comma-separated list of directives. Common values: index, follow (default — index this page, follow its links), noindex, follow (don't show in search but follow links), noindex, nofollow (completely ignore — for admin pages, login pages, thank-you pages).
HTML — canonical and robots
<!-- Canonical — always point to the clean version of the URL -->
<link rel="canonical"
      href="https://k2infocom.com/tutorial/html/html-meta-seo.html">

<!-- Allow Google to index and follow links (default) -->
<meta name="robots" content="index, follow">

<!-- Block indexing — use for /login, /thank-you, /admin pages -->
<meta name="robots" content="noindex, nofollow">

<!-- Index page but don't follow links (thin content pages) -->
<meta name="robots" content="index, nofollow">

<!-- Googlebot-specific override (when you need different
     instructions for Google vs other crawlers) -->
<meta name="googlebot" content="noindex, nosnippet">
Directive Effect on Crawlers When to Use
index Include this page in search results Default for all public-facing pages — don't need to set explicitly
noindex Do not include this page in search results Thank-you pages, login, admin, duplicate/staging pages, print versions
follow Follow all links on this page and pass link equity Default for all pages — set explicitly with noindex when needed
nofollow Do not follow links — no link equity passes through Paid/sponsored links, user-generated content pages, low-trust pages
nosnippet Do not show a description snippet in results When you don't want Google to show extracted text below the title
noimageindex Do not index images on this page Pages with stock photos or images you don't own the rights to

Structured Data — JSON-LD & Schema.org

Structured data is machine-readable information added to a page to help Google understand what the content is about. When implemented correctly, it powers Rich Results in Google Search — star ratings, FAQ dropdowns, recipe cards, event boxes, breadcrumb trails, and "How-to" guides directly in search results. The recommended format is JSON-LD (JavaScript Object Notation for Linked Data) embedded in a <script type="application/ld+json"> tag.

HTML — Article schema (JSON-LD)
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "TechArticle",
  "headline": "HTML Meta Tags & SEO — Complete Guide",
  "description": "Master all HTML meta tags and SEO elements.",
  "author": {
    "@type": "Organization",
    "name": "K2infocom"
  },
  "publisher": {
    "@type": "Organization",
    "name": "K2infocom",
    "logo": {
      "@type": "ImageObject",
      "url": "https://k2infocom.com/images/logo.png"
    }
  },
  "datePublished": "2025-01-01",
  "dateModified": "2025-07-01",
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://k2infocom.com/tutorial/html/html-meta-seo.html"
  },
  "educationalLevel": "Beginner"
}
</script>
HTML — BreadcrumbList schema (enables breadcrumbs in Google results)
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [
    {
      "@type": "ListItem",
      "position": 1,
      "name": "Home",
      "item": "https://k2infocom.com/"
    },
    {
      "@type": "ListItem",
      "position": 2,
      "name": "HTML Tutorial",
      "item": "https://k2infocom.com/tutorial/html/"
    },
    {
      "@type": "ListItem",
      "position": 3,
      "name": "Meta Tags & SEO",
      "item": "https://k2infocom.com/tutorial/html/html-meta-seo.html"
    }
  ]
}
</script>
Test Your Structured Data
Use Google's free Rich Results Test at search.google.com/test/rich-results to validate your JSON-LD schema. It shows exactly which rich result types your page qualifies for and flags any errors in your markup. Run it after every schema change.

Complete <head> Template

Here is a production-ready, copy-paste <head> template covering every category of meta tag for a typical tutorial or blog page:

HTML — Production-ready complete <head> template
<head>

  <!-- ── ESSENTIAL ──────────────────────────────────────── -->
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="theme-color" content="#e44d26">

  <!-- ── SEO ────────────────────────────────────────────── -->
  <title>Page Title — Keyword | Brand Name</title>
  <meta name="description"      content="150-160 char description with keyword.">
  <meta name="keywords"         content="keyword1, keyword2, keyword3">
  <meta name="author"           content="K2infocom">
  <meta name="robots"           content="index, follow">
  <link rel="canonical"        href="https://k2infocom.com/your-page.html">
  <link rel="icon"             type="image/png" href="/images/logo.png">

  <!-- ── OPEN GRAPH ─────────────────────────────────────── -->
  <meta property="og:title"        content="Page Title — Brand">
  <meta property="og:description"   content="Page description for social share.">
  <meta property="og:image"         content="https://k2infocom.com/og-image.jpg">
  <meta property="og:url"           content="https://k2infocom.com/your-page.html">
  <meta property="og:type"          content="article">
  <meta property="og:site_name"     content="K2infocom">
  <meta property="og:image:width"   content="1200">
  <meta property="og:image:height"  content="630">

  <!-- ── TWITTER CARD ───────────────────────────────────── -->
  <meta name="twitter:card"        content="summary_large_image">
  <meta name="twitter:title"       content="Page Title">
  <meta name="twitter:description"  content="Page description.">
  <meta name="twitter:image"        content="https://k2infocom.com/og-image.jpg">
  <meta name="twitter:site"         content="@k2infocom">

  <!-- ── STRUCTURED DATA ────────────────────────────────── -->
  <script type="application/ld+json">
  {
    "@context": "https://schema.org",
    "@type": "WebPage",
    "name": "Page Title",
    "url": "https://k2infocom.com/your-page.html"
  }
  </script>

</head>

Common Mistakes — Do's & Don'ts

These are the most frequent meta tag and SEO mistakes beginners make:

Do — Correct
<!-- charset first, before title -->
<meta charset="UTF-8">
<title>Unique per-page title (55 chars)</title>

<!-- Unique description per page -->
<meta name="description"
      content="Specific 155-char description
      with the page's primary keyword.">

<!-- Absolute URL for OG image -->
<meta property="og:image"
      content="https://k2infocom.com/img.jpg">
Don't — Wrong
<!-- charset after title — may misread title -->
<title>Page</title>
<meta charset="UTF-8">

<!-- Same description on every page -->
<meta name="description"
      content="K2infocom - Best courses">

<!-- Relative URL for OG image — breaks -->
<meta property="og:image"
      content="/images/og.jpg">

Try It Yourself

The editor below contains a complete <head> template. Click Open in Editor to edit and observe how changes to title, description and OG tags affect the simulated search/social previews rendered on the right.

Live Editor
✎ Editor
👁 Preview
Try This
In the editor, change the <title> text and the og:title content value — click Open in Editor, then watch both the SERP preview and the Facebook preview update live. Try adding noindex, nofollow to the robots meta and see it appear in the meta list at the bottom.
Free Resource
HTML5 Cheat Sheet — All Tags & Attributes
One printable PDF with a complete copy-paste <head> template covering all meta tags, OG, Twitter Cards, canonical, robots directives, and JSON-LD schemas.
Download PDF
Featured Course — Enroll Now
Modern Web Development With AI
Master HTML, CSS, JavaScript, React, and Node.js in one industry-ready curriculum with real projects and placement support.
120+
Chapters
40 hrs
Content
10
Projects
4.9 ⭐
Rating
HTML5 CSS3 JavaScript React.js Node.js MongoDB AI Tools

Quick Check — Chapter 18

Expand each question to check your understanding before moving on to the multiple choice quiz.

Questions & Answers
The browser starts parsing HTML characters before it finishes reading the document. If it encounters the <title> or any text before the charset declaration, it may misinterpret those characters using its default encoding (often ASCII or the OS locale). Placing <meta charset="UTF-8"> first ensures the browser knows how to decode every subsequent byte in the document — including the title text — before it processes it. This prevents broken characters (called mojibake) from appearing. The HTML5 spec requires it to appear within the first 1024 bytes of the document.
Without the viewport meta tag, mobile browsers use their default viewport width of ~980px (simulating a desktop screen) and then scale the page down to fit the physical screen. On a 390px wide phone, this makes all text and buttons tiny and unreadable — users must pinch-zoom to read anything. Responsive CSS breakpoints become completely ineffective because the browser thinks the page is 980px wide. Adding width=device-width, initial-scale=1.0 tells the browser to use the actual device width and render at 100% zoom — making responsive CSS work correctly.
robots.txt is a file at the root of your domain (/robots.txt) that tells crawlers which URLs they are allowed to visit — it prevents crawlers from fetching certain pages at all. However, if a crawler doesn't fetch the page, it can still index a URL it already knows about through links. The robots meta tag is per-page HTML that tells crawlers what to do with a page they have already fetched — whether to index it, show a snippet, or follow its links. Use robots.txt to block crawling of large sections (e.g. /admin/). Use meta robots to control indexing of individual pages (e.g. noindex on a thank-you page).
When Facebook, LinkedIn, WhatsApp, or Twitter scrape your page to generate a share preview, their servers fetch the OG image directly from the URL in the meta tag. These servers are located externally — they don't know your domain, so a relative path like /images/og.jpg has no base URL to resolve against. They would literally try to fetch /images/og.jpg which is invalid. An absolute URL like https://k2infocom.com/images/og.jpg works from any server anywhere. The same rule applies to og:url and Twitter image tags.
The <link rel="canonical"> tag tells Google the authoritative URL of the current page. Even without intentional duplicates, pages often have multiple accessible URLs: with and without trailing slash, with ?utm_source= tracking parameters, with and without www, via HTTP and HTTPS. Without a canonical, Google may split link equity between these variants or penalise your site for duplicate content. By setting a self-referencing canonical on every page, you consolidate all link signals to one URL, prevent tracking parameters from creating duplicate pages in the index, and make it explicit which URL should rank. It takes 30 seconds to add and protects years of SEO work.
JSON-LD (JavaScript Object Notation for Linked Data) is a way to embed machine-readable structured data inside a <script type="application/ld+json"> tag in the HTML head. It uses vocabulary from schema.org to describe what a page's content represents — an Article, a Course, a Product, a Recipe, an Event, an FAQ, etc. Rich results are enhanced search listings powered by this structured data — things like star ratings below a product, FAQ dropdowns that expand in the results, event date/time boxes, recipe ingredient panels, and "How-to" step previews. These appear directly in Google Search before the user even clicks, dramatically improving click-through rates. Google's Rich Results Test validates whether your schema is correct.
Multiple Choice Questions
MCQ 1 of 4
Which attribute pair is used for Open Graph meta tags (Facebook, LinkedIn)?
MCQ 2 of 4
Which robots meta directive tells Google not to show this page in search results?
MCQ 3 of 4
What is the recommended minimum image size for an Open Graph og:image?
MCQ 4 of 4
Which script type is used to embed JSON-LD structured data in HTML?
Chapter Summary
  • Essential meta tags on every page: <meta charset="UTF-8"> (first in head), viewport width=device-width, initial-scale=1.0 (mobile rendering), theme-color (browser chrome colour).
  • SEO meta tags: <title> 50–60 chars (keyword first), description 150–160 chars (unique per page), robots: index, follow (default), noindex, nofollow for login/admin pages.
  • Open Graph uses property/content pairs. Essential 4: og:title, og:description, og:image (1200×630px absolute URL), og:url. Controls Facebook, LinkedIn, WhatsApp previews.
  • Twitter Cards use name/content pairs. twitter:card="summary_large_image" is the most impactful type. Falls back to OG if absent.
  • <link rel="canonical"> prevents duplicate content penalties — set it on every page pointing to the clean canonical URL. noindex blocks pages from appearing in search results.
  • JSON-LD structured data in <script type="application/ld+json"> powers Google Rich Results — star ratings, FAQs, breadcrumbs, events, articles. Validate with Google's Rich Results Test.
~10 min read
Beginner level
Chapter 18 of 40

Rate Us on Google

4.8 / 5
Enjoying this tutorial?
If this tutorial helped you, a 5-star Google review means a lot. It helps other learners discover our free content and motivates us to keep improving.
500+ Reviews (Target)
Write a Google Review
Join WhatsApp Channel