HTML - <meta> Tag



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.

The <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.

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

Following is the syntax of <meta> tag −

<meta attribute-name="value">

Specific Attributes

The HTML <meta> tag also supports the following additional attributes −

S.No. Attribute & Description
1

name

Name for the property. Can be anything. Examples include, keywords, description, author, revised, generator etc.
2

content

Specifies the property's value.
3

scheme

Specifies a scheme to interpret the property's value (as declared in the content attribute).
4

http-equiv

Used for http response message headers. For example, http-equiv can be used to refresh the page or to set a cookie. Values include content-type, expires, refresh and set-cookie

Example

Following is an example, where we are adding HTML, Meta Tags, 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>

When we execute the above code, the output window will pop up, displaying the text on the webpage.

Example

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>

On running the above code, it will generate an output consisting of text displayed on the webpage.

Example

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>

When we execute the above code, the output window will pop up, displaying the text on the webpage.

Example

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>

On running the above code, it will generate an output consisting of text displayed on the webpage.

html_tags_reference.htm
Advertisements