Favorites

Meta Tags in HTML: A Comprehensive Guide

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Meta Tags HTML

What are meta tags?

Meta tags are HTML elements that give information about a web page (called metadata) to browsers, search engines and social media sites. They go inside the <head> section of a page and aren't shown on the page itself, but they affect how it's displayed, how it appears in search results, and what people see when they share a link.

Most meta tags follow the same pattern: a name saying what the information is, and a content holding the value:

<meta name="description" content="A short summary of the page.">

You'll also see a few variations:

  • charset: a special attribute just for the character encoding.
  • http-equiv: instructions that act like information normally sent by the web server.
  • property: used by Open Graph tags for social sharing.

Here's a preview of where some of this information appears, using the tags covered in this guide:

Results

Browser tab: <title> and icon

Meta Tags in HTML: A Comprehensive Guide | CSSPortal

Search result: <title> and description

CSSPortal
https://www.cssportal.com › blog › meta-tags
Meta Tags in HTML: A Comprehensive Guide | CSSPortal
Learn which HTML meta tags matter today, what each one does, and which outdated tags you can safely remove.

Social link preview: Open Graph tags

<meta> tagsog:image, 1200 × 630
cssportal.com
Meta Tags in HTML: A Comprehensive Guide
Which meta tags matter today, and which you can remove.

These are simplified, generic examples. Each browser, search engine and social platform shows this information in its own style.

The essential tags

Every page should have these four.

Character encoding

<meta charset="utf-8">

This tells the browser how the text in the file is encoded, so that characters like é, ü, “curly quotes” and emoji display correctly instead of as garbled symbols. UTF-8 is the standard encoding for the web, and the one you should always use.

Tip: make this the very first thing inside <head>. Browsers need to find it within the first 1024 bytes of the page, before they start reading any text.

Viewport

<meta name="viewport" content="width=device-width, initial-scale=1">

Without this tag, phones pretend to have a wide desktop screen and shrink the whole page down to fit, leaving text tiny and unreadable. width=device-width tells the browser to use the device's real width, and initial-scale=1 starts the page at normal zoom. It's what makes responsive designs work on mobile.

Title

<title>Meta Tags in HTML: A Comprehensive Guide | CSSPortal</title>

Strictly speaking, <title> isn't a meta tag, but it's the most important piece of metadata on the page. It's shown in the browser tab, used as the default name for bookmarks, read out by screen readers (software that reads pages aloud) when the page loads, and usually shown as the clickable heading in search results.

  • Make every page's title unique and descriptive.
  • Put the most important words first, as long titles get cut off.
  • Adding your site name at the end, after a separator such as |, is a common convention.

Description

<meta name="description" content="Learn which HTML meta tags matter today, what each one does, and which outdated tags you can safely remove.">

The description is a short summary of the page. Search engines often show it under the title in their results, so a clear, accurate description can encourage people to click. Search engines may sometimes write their own snippet instead, based on the page's content and what the person searched for.

Tip: there's no fixed length limit, but descriptions are usually cut off after around 150–160 characters in search results, so put the key information first. Write a unique description for each page.

Robots

The robots meta tag tells search engines whether to include a page in their results and whether to follow its links:

<!-- Keep this page out of search results -->
<meta name="robots" content="noindex">

<!-- Keep it out of results, and don't follow its links -->
<meta name="robots" content="noindex, nofollow">

<!-- Allow large image previews in results -->
<meta name="robots" content="max-image-preview:large">
  • You don't need index, follow. The original version of this post used it as an example, but it's the default behaviour, so the tag does nothing. Only add a robots tag when you want to change something.
  • Use noindex for pages that shouldn't appear in search results, such as thank-you pages, internal search results or staging copies of your site.
  • Don't block a noindex page in your robots.txt file. If search engines can't visit the page, they never see the noindex tag, and the page may still appear in results.

Canonical link

If the same content can be reached at more than one address, for example with and without tracking parameters, a canonical link tells search engines which address is the main one:

<link rel="canonical" href="https://www.cssportal.com/blog/meta-tags/">

It's a <link> rather than a <meta> tag, but it lives in the <head> alongside them and is just as important for search.

Search engine verification

Tools like Google Search Console may ask you to add a verification meta tag to prove you own a site. Copy the tag exactly as the tool gives it to you:

<meta name="google-site-verification" content="your-unique-code">

Social sharing: Open Graph and X cards

When someone shares a link on social media or in a messaging app, the app builds a preview card from the page's Open Graph tags. The Open Graph protocol was created by Facebook, but it's now used by almost every platform that shows link previews.

<meta property="og:type" content="article">
<meta property="og:title" content="Meta Tags in HTML: A Comprehensive Guide">
<meta property="og:description" content="Which meta tags matter today, and which you can remove.">
<meta property="og:url" content="https://www.cssportal.com/blog/meta-tags/">
<meta property="og:image" content="https://www.cssportal.com/images/meta-tags-share.png">
<meta property="og:image:alt" content="An HTML head section with meta tags highlighted">
<meta property="og:site_name" content="CSSPortal">
  • og:image must be a full URL, starting with https://. A relative path like /images/share.png won't work.
  • A size of 1200 × 630 pixels is the commonly recommended image size. It works well as a large preview on most platforms.
  • Add og:image:alt to describe the image for people using screen readers.

X (Twitter) cards

X uses its own twitter: tags, but it falls back to the matching Open Graph tags for the title, description and image. So if you already have Open Graph tags, you usually only need to choose the card style:

<meta name="twitter:card" content="summary_large_image">

summary_large_image shows a large image above the title, while summary shows a small square thumbnail beside it. X doesn't support SVG images for cards, so use PNG, JPG or WebP.

Tip: many platforms cache link previews. If you change your tags and the old preview still appears, most platforms offer a debugging or preview tool that fetches your page again.

Browser and device tags

Theme colour

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

Some browsers, mainly on mobile, use this colour to tint the address bar and surrounding interface so it blends with your design. The media attribute lets you set different colours for light and dark modes.

Colour scheme

<meta name="color-scheme" content="light dark">

This tells the browser your page supports both light and dark modes, so it can style the default background, scrollbars and form controls to match before your CSS has even loaded. That helps avoid a white flash on dark-mode devices. It's the same as setting color-scheme: light dark on :root in CSS, but takes effect sooner.

Icons

Favicons (the small icons in browser tabs and bookmarks) are added with <link> tags. A modern, minimal set looks like this:

<link rel="icon" href="/favicon.ico" sizes="32x32">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">  <!-- 180 × 180 pixels -->

Tags to skip or use with care

Keywords: skip it

<meta name="keywords" content="html, meta tags, seo">

Search engines once used this tag, but it was so widely stuffed with irrelevant words that they stopped. Google states that it doesn't use the keywords tag at all, for indexing or ranking. It does no good, and it shows your target keywords to anyone who views your page's source. It's safe to remove.

Content-Type: you don't need both

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

This older tag does exactly the same job as <meta charset="utf-8">. Use the shorter charset version, and don't include both, as a page should only declare its encoding once.

Refresh: use a server redirect instead

<meta http-equiv="refresh" content="5; url=https://www.cssportal.com/">

This reloads the page, or sends visitors to another address, after a number of seconds. It causes problems:

  • Pages that change or reload without warning can disorientate people, especially screen reader users, and interrupt anyone who's still reading.
  • For moving a page permanently, a server-side 301 redirect is faster and clearer for both browsers and search engines. Google recommends using one instead.

Viewport: never disable zooming

<!-- Don't do this -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

Adding user-scalable=no or maximum-scale=1 stops people from zooming in, which many people with low vision rely on. Some browsers now ignore these settings for this reason. Stick to width=device-width, initial-scale=1.

Author and copyright: optional

<meta name="author" content="Your Name">

The author tag is a valid way to name a page's author, but search engines don't use it for ranking, and visitors never see it. If authorship matters, show it on the page and include it in structured data (see below). The copyright tag isn't part of the HTML standard, so a visible copyright notice in your footer is more useful.

Structured data with JSON-LD

Structured data describes your content in a standard format that search engines can read reliably: that a page is an article, who wrote it, when it was published, and so on. It can make your pages eligible for richer search results. The most common format is JSON-LD, added in a <script> tag using the schema.org vocabulary:

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Article",
  "headline": "Meta Tags in HTML: A Comprehensive Guide",
  "description": "Which meta tags matter today, and which you can remove.",
  "datePublished": "2024-01-15",
  "dateModified": "2026-11-09",
  "author": {
    "@type": "Person",
    "name": "Author Name"
  }
}
</script>

Structured data should always match what's visible on the page. Google's Rich Results Test lets you check that yours is valid.

A complete head template

Here's a solid starting point for a typical page, putting everything together:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Page Title | Site Name</title>
  <meta name="description" content="A clear, unique summary of this page.">
  <link rel="canonical" href="https://www.cssportal.com/page/">

  <!-- Light and dark mode -->
  <meta name="color-scheme" content="light dark">
  <meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)">
  <meta name="theme-color" content="#111827" media="(prefers-color-scheme: dark)">

  <!-- Icons -->
  <link rel="icon" href="/favicon.ico" sizes="32x32">
  <link rel="icon" href="/icon.svg" type="image/svg+xml">
  <link rel="apple-touch-icon" href="/apple-touch-icon.png">

  <!-- Social sharing -->
  <meta property="og:type" content="website">
  <meta property="og:title" content="Page Title">
  <meta property="og:description" content="A clear, unique summary of this page.">
  <meta property="og:url" content="https://www.cssportal.com/page/">
  <meta property="og:image" content="https://www.cssportal.com/images/share.png">
  <meta property="og:image:alt" content="Describe the image here">
  <meta name="twitter:card" content="summary_large_image">

  <link rel="stylesheet" href="/styles.css">
</head>

Don't forget lang: the lang attribute on the <html> element isn't a meta tag, but it's just as important. It tells screen readers which language to pronounce the page in, and helps browsers offer translation and choose the right hyphenation and quotation marks.

Best practices

  • Make titles and descriptions unique for every page, and keep them accurate to the content.
  • Remove tags that do nothing, like keywords and robots set to index, follow.
  • Test your tags. Google Search Console shows how your pages appear in search, and social platforms offer preview tools for link cards.
  • Remember the bigger picture. Meta tags help search engines and social sites present your pages well, but useful, well-written content is what makes people want to visit.

Wrapping up

A handful of meta tags do almost all of the work: charset, viewport, a good <title> and a clear description. Add Open Graph tags for social sharing, robots only when you need to change the defaults, and color-scheme and theme-color for a polished feel. Skip the outdated tags, and your <head> will be short, tidy and effective.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.