Skip to main content

HTML Tags

HTML <meta> Tag

Written by Updated HTML <meta> Tag exercises

The meta tag puts information about the page into the head: the character set, the mobile viewport, a description for search results. It shows nothing on the page, and has no closing tag.

Most pages need only three: charset, viewport and description. SEO-related ones are covered in detail in HTML Meta Tags for SEO.

Syntax

html

<meta charset="UTF-8">
<meta name="description" content="This is an example of meta description">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
AttributeWhat it does
charsetThe character encoding. Always UTF-8.
nameWhat kind of information, like description, viewport or author.
contentThe information itself.
http-equivImitates a server header. Mostly used for refresh, which is rarely a good idea.
propertyUsed instead of name by Open Graph tags for social sharing.

Example

html

<!DOCTYPE html>
<html>
<head>
  <title>Meta Tag Example</title>
  <meta charset="UTF-8">
  <meta name="description" content="This page demonstrates the use of meta tags.">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
  <h1>Welcome to My Website</h1>
  <p>This page uses meta tags to provide metadata for browsers and search engines.</p>
</body>
</html>

The page shows only the heading and the paragraph. All the meta tags in the head are invisible, but browsers, search engines and social sites read them.

The three every page needs

A minimal, correct head

html

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="A short summary of this page, about 150 characters.">
  • charset makes sure every character, from é to ₹ to emojis, displays correctly. Put it first.
  • viewport makes the page fit phone screens and is needed for responsive design.
  • description is often shown under your title in Google results.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

Good to know

  • keywords is ignored by Google and Bing; you can leave it out.
  • Do not use <meta http-equiv="refresh"> to redirect pages; use a server redirect instead.
  • Meta tags only work inside the <head>.

HTML <meta> Tag exercises

Describe the page

Write the meta tag that gives a page this description: Learn HTML step by step.

Result

Check your answer to see it here.