HTML - <meta> Tag



HTML <meta> tag is used to provide such additional information. This tag is an empty element and does not have a closing tag but it carries information within its attributes.

HTML lets you specify metadata an additional important information about a document in a variety of ways. The META elements can be used to include name/value pairs describing properties of the HTML document, such as author, expiry date, a list of keywords, document author etc.

You can include one or more meta tags in your document based on what information you want to keep in your document but in general, meta tags do not impact physical appearance of the document so from appearance point of view, it does not matter if you include them or not.

Syntax

<meta attribute-name="value">

Attribute

HTML meta tag supports Global and accepts some specific attributes as well which is listed below.

Attribute Value Description
name application-name
author
description
generator
keywords
viewport
Name for the property. Can be anything. Examples include, keywords, description, author, revised, generator etc.
content text Specifies the property's value.
charset character_set Specifies character encoding to for HTML document.
http-equiv content-security-policy
content-type
default-style
refresh
Used for http response message headers. For example, http-equiv can be used to refresh the page or to set a cookie.

Examples of HTML meta Tag

Bellow examples will illustrate the usage of meta tag. Where, when and how to use meta tag.

Defining Metadata

Following is an example, where we are adding Meta Tag, metadata as important keywords about the document.

<!DOCTYPE html>
<html>
<head>
   <title>Meta Tags Example</title>
   <meta name="keywords" content="HTML, Meta Tags, Metadata" />
</head>
<body>
   <p>Hello HTML5!</p>
</body>
</html>

Specifying Meta DEscription through meta Tag

In the following example we are going to use the <meta> tag to give a short description of the document. This can again be used by various search engines while indexing your webpage for search purposes.

<!DOCTYPE html>
<html>
<head>
   <title>Meta Tags Example</title>
   <meta name="keywords" content="HTML, Meta Tags, Metadata" />
   <meta name="description" content="Learning about Meta Tags." />
</head>
<body>
   <p>WELCOME TO TP</p>
</body>
</html>

Adding informative Metadata

Let’s consider the following example, where we are going to use the <meta> tag to give information about when the document was last updated. This information can be used by various web browsers while refreshing your webpage.

<!DOCTYPE html>
<html>
<head>
   <title>Meta Tags Example</title>
   <meta name="keywords" content="HTML, Meta Tags, Metadata" />
   <meta name="description" content="Learning about Meta Tags." />
   <meta name="revised" content="Tutorialspoint, 3/7/2014" />
</head>
<body>
   <p>Hello</p>
</body>
</html>

Refreshing HTML page after Certain Time

Let’s look at the following example, where we are going to keep refreshing the page every 5 seconds.

<!DOCTYPE html>
<html>
<head>
   <title>Meta Tags Example</title>
   <meta name="keywords" content="HTML, Meta Tags, Metadata" />
   <meta name="description" content="Learning about Meta Tags." />
   <meta name="revised" content="Tutorialspoint, 3/7/2014" />
   <meta http-equiv="refresh" content="5" />
</head>
<body>
   <p>Hello World</p>
</body>
</html>

Supported Browsers

Tag Chrome Edge Firefox Safari Opera
meta Yes Yes Yes Yes Yes
html_tags_reference.htm
Advertisements