The <meta> tag specifies metadata for the document. The Metadata will not be displayed on the page but will be machine parsable. The HTML <meta>tag is for declaring metadata for the HTML document. Metadata can include description, keyword, author, etc. It is also used to refresh the page. The meta tag is placed between opening and closing <head> tags.
Metadata is data (information) about data. The <meta> tag can be used by the browsers, search engines or other web services. It provides the information for search engines of your page such as description, refreshes, keyword, etc. The <meta> tag always goes inside the <head> tag. Metadata is always ed as name/value pairs. The Content attribute must be defined if the name or the http-equiv attribute is defined. If none of these are defined then the content attribute cannot be defined.
HTML5 has a new attribute charset, that makes it easier to define the charset.
Syntax
The syntax of the <meta> tag is:
<meta name="value" content="value" http-equiv="value" charset="value"/>
Browser Support
The <meta> tag is supported in all major browsers.
Attributes of Meta Tag
The <meta> tag has four attributes; they are:
the name attribute has the following values:
application name: This value represents the name of the web application.
author: The value is a string and must specify the name of the author of the page.
description: The value specifies the description of the web page.
generator: The value specifies the name of the software package used.
keyword: These represent the keywords of the page.
This attribute has the following values:
refresh: To set the refresh time of the web page.
default-style: To provide the style sheet set.
content-language: the language of the document.
It specifies the metadata of the document.
It specifies the character encoding used in the document.
Example of the <meta> tag in HTML5
- <!DOCTYPE html>
- <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Meta Tag in HTML5</title>
- <meta name="description" content="Html5 article"/>
- <meta name="keywords" content="c#,html5,asp.net,meta tag"/>
- <meta name="generator" content="Frontpage"/>
- <meta name="description" content="Html5 article"/>
- <meta name="author" content="Ashwani Tyagi"/>
- <meta name="description" content="Html5 article"/>
- <meta http-equiv="refresh" content="5;url=http://www.gmail.com/"/>
- <meta charset="UTF-8"/>
- </head>
- <body>
- <p>It is used to Specify the metadata of the document.</p>
- </body>
- </html>
Output
Page redirected to Gmail page