DEV Community

Cover image for HTTP-Equiv(alent)
Kiran Raj R
Kiran Raj R

Posted on • Edited on

HTTP-Equiv(alent)

The meta tag is used to convey meta information about the webpage to the web browsers. The information conveyed is called "metadata". The data is not visible in the page or is useful for the clients, the information is used by search engines and web crawlers.

Sometimes we may not have the access to the server that is hosting our web documents, so to send additional information we can use the http-equiv meta tag. If we have access to the server configurations we can ignore the http-equiv tags, as we don't have access to the server configuration http-equiv help us to send some additional information to browsers. Http-equiv simulate an HTTP response header, the attribute lets you to send additional information to the browser in the form of http header.

Lets look at an example

<META HTTP-EQUIV="Expires" CONTENT="Fri, 26 Mar 2021 17:49:00 GMT">
<META HTTP-EQUIV="Keywords" CONTENT="Metadata, httpequiv">

The above code will add the below data to the response header.

Expires: Fri, 26 Mar 2021 17:49:00 GMT
Keywords: Metadata, httpequiv

Some of the most used values for http-equiv are mentioned below.

  1. <meta http-equiv=”expires” content=”date-time” />
    The date indicate the date and time in which the document will expire, when the expire time is reached the document will be reloaded.

  2. <meta http-equiv=”refresh” content=”n;url=url” />
    This code cause the document to be refreshed after n seconds and if the url is specified, after the refresh time the page will redirect to the mentioned url. Should avoid the redirect, it is not accessible.

  3. <meta http-equiv="default-style" content="/style.css">
    Sets the name of the default alternative stylesheet set, the CSS file must be linked to the document for this to work.

  4. <meta http-equiv=”content-type” content=”type; charset=charset” />
    This meta tag inform the type of the document and the character set used in the document. For example <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /> Tells the browser that the encoding is utf-8 and the document is of the type html.

Top comments (0)