HTML - http-equiv Attribute



HTML http-equiv is an attribute used to specify an HTTP header for the document's metadata, typically used to control the behavior of the browser or server. This attribute is named http-equiv, because all the allowed values are names of particular HTTP headers.

If the value of the http-equiv attribute is set to refresh and the content attribute accepts the time interval and URL of any website or page, it will refresh the page and redirect it to the given URL after the time interval. The refresh instruction specifies the number of seconds until the page should be reloaded, only if the content attribute contains a non-negative value.

Syntax

<meta http-equiv = "value"></meta>

Following are the list of values supported by the http-equiv

  • content-security-policy
  • content-type
  • default-style
  • x-ua-compatible
  • refresh

Applies On

Below listed elements allow using of the HTML http-equiv attribute

Element Description
<meta> HTML <meta> tag is used to add meta data to a webpage.

Example of HTML http-equiv Attribute

Below examples will illustrate the HTML http-equiv attribute, where and how we should use this attribute!

Refresh webpage using 'http-equiv' Attribute

In the following example, the HTML 'http-equiv' attribute is used within an <meta> element to define a pragma directive. We specify the string "refresh" as the value of this attribute which defines that the page should refresh with respect to the time interval.

<!DOCTYPE html>
<html lang="en">

<head>
   <!--http-equiv attribute-->
   <meta http-equiv="refresh" content="10">
   <title>HTML 'http-equiv' attribute</title>
</head>

<body>
   <h3>
      Example of the HTML 'http-equiv' attribute
   </h3>
   <p>
      The page should be refreshed automatically 
      with respect to the time interval.
   </p>
</body>

</html>

Redirect webpage after Certain Time

Consider the another scenario, where we are going to use the ‘http-equiv’ attribute within the <meta> tag to redirect the current webpage to a different page after certain interval.

<!DOCTYPE html>
<html lang="en">
<head>
   <!-- HTML http-equiv Attribute-->
   <meta 
      http-equiv="refresh" 
      content="5;url=/html/html_overview.htm" >
   <title>HTML 'http-equiv' attribute</title>
</head>
<body>
   <h3>HTML 'http-equiv' Attribute</h3>
   <p>
      The page will redirect to the HTML Introduction 
      website after 5 seconds.
   </p>
</body>
</html>

Supported Browsers

Attribute Chrome Edge Firefox Safari Opera
http-equiv Yes Yes Yes Yes Yes
html_attributes_reference.htm
Advertisements