Meta Tag in HTML

In HTML documents, it becomes important to specify some additional features about the data/content of the website being entered. The meta tag is used enter meta data (basic information about the HTML webpage) about the content on an HTML page. The meta tag is declared within the head tag. This is used to specify specific properties of the HTML document.

Attributes of the Meta Tag

AttributeAbout
charsetUsed to specify character encoding for the HTML document. This is nothing but a process of representing individual characters based on an encoding scheme
http-equivUsed to provide an HTTP header for the value of the content attribute. This is significant in identifying HTML documents.
nameUsed to specify a name for the metadata. This is significant in naming the HTML document’s meta data specifics.
schemeUsed to specify a scheme to interpret the value of the mentioned attributes. It is significant in adjusting the overall layout and structure of the documents
contentUsed to specify the value of the attribute. This is used to signify what content is actually held by the document.

Use of Meta Tag

Example 1: Specifying Keywords

In this example, we are going to see how to specify keywords in a given meta tag.

<meta name="keywords" content="HTML tags">

Example 2: Specifying Document Description

The description for the HTML document could be described in the meta tag.

<meta name="description" content="Scaler Topics">

The description in the webpage would be described as Scaler Topics.

Example 3: Document Refresh

This code would be used to refresh the contents of the page after 20 seconds.

<meta http-equiv="refresh" content="20">
The document would be refreshed with new, dynamic content after every 20 seconds.

Example 3: Document Revision

Meta tag could be used to make revisions to the document.

 
<meta name="revised detail" content="last updated time">

Any changes in the document would be revised automatically from the last updated time. This is the functionality of the meta tag.

Example 4: Page Redirect

Meta tag can be used to redirect traffic from a given site to another website.

<meta http-equiv="refresh" content="2;url=http://scaler.com" />

This means that they could redirect users from the given website to any other related websites or links. This is the functionality of the meta tag.

Example 5: Setting Author Name

Meta tag can be used to define the name of the author of an HTML document.

<meta name="author" content="Jane Doe">

This is used to set the name of the author of the HTML document. This is the functionality of the meta tag.

Example 6: Set Cookies

Cookies are packets of data that a server sends a browser each time it requests information. The meta tag can be used to set cookies.


<meta http-equiv = "Set-Cookie">

These are used to set cookies in the web document. This is the functionality of the meta tag.

Example 7: Specify Character Set

The character set can be specified using the meta tag.A character set refers to the composite number of different characters that are being used and supported by a computer software and hardware

<meta charset="character_set">

Example 8: Setting Viewport

To ensure that out website can be accessed and viewed by multiple devices, the viewport is fixed accordingly using the meta tag.

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

This signifies viewing properties of the document. The width=device-width part sets the width of the page to be set according to the screen-width of the device. The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the web browser.