Meta tags in HTML | Meta tags with examples

How the Meta tags are used in HTML?

The Meta tag is used to describe the aspects of your HTML document for the benefit of various processors that are going to use this document. It is a data that is not displayed in your page but it will help the various processors that use it like web server or the client’s browser. We are going to discuss the different uses of the Meta tag here. See the code below and we will explain it.

Code:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8" />

<meta http-equiv="refresh" content="5; url=http:www.howtocode.pk" />

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

<title>

HTML Meta Information

</title>

<link rel="stylesheet" type="text/css" href="mystyles.css" />

</head>

<body>

<h1>

HTML Meta Information

</h1>

<p>

Text goes here.

</p>

</body>

</html>

Output:

The page will wait for five seconds and then redirect to www.howtocode.pk.

In the above code we are using three Meta tags. Of course while using the third one you can delete the first one because it covers the desired action. But we have used it to explain it to you.

The first Meta tag is used to tell the browser that what character set will be used in the document. It will help the browser to display it properly.

The second Meta tag is used to simulate the http headers which are used to redirect from one page to the other. In this Meta tag there are to attributes first is “http-equiv” which has the “refresh” value. The second attribute is the “content” attribute, which is specifying the time of the delay and where to go after the delay time. This tag actually tells the browser to act on this header as you have received it from the server. It does not do anything on the server.

The third Meta tag describes or it mimics the content type headers. In this tag we are telling the browser and sending what type of contents we want the browser to use.

Meta tags were used by the search engines to rank the page. Especially the “keyword” Meta tag was used by the search engines to rank on the basis of these keywords but it was massively misused and now the major search engines are not using this to rank a page.

Comments