HTML http-equiv Attribute
Description
The http-equiv
attribute in HTML is used to provide HTTP header information to the browser. It stands for "HTTP equivalent," and it allows an HTML document to send HTTP information to the client without using HTTP headers in the response. This attribute is typically used within a <meta>
tag in the <head>
section of an HTML document.
The http-equiv
attribute can serve various purposes, including:
Controlling Cache Behaviour: Using values like
expires
,pragma
, orcache-control
, developers can influence how browsers cache the webpage, potentially improving load times and reducing server load for subsequent visits.Specifying Character Encoding: With
content-type
, the character set of the document (e.g., UTF-8) can be declared, ensuring that text is properly displayed across different browsers and devices.Refreshing or Redirecting: The
refresh
value can be used to refresh the page automatically after a specified number of seconds, or to redirect the user to another URL.Setting Cookies: Although less common,
set-cookie
can be used to set HTTP cookies directly from HTML documents.Controlling Display or Behavior: Attributes like
x-ua-compatible
can be used to advise the browser on how to render the page, often for compatibility with specific versions of Internet Explorer.
The general syntax for using the http-equiv
attribute within a <meta>
tag looks like this:
<meta http-equiv="type_of_header" content="value">
Where type_of_header
specifies the type of HTTP header information you're mimicking, and value
provides the necessary information or directive for that header type.
While the http-equiv
attribute offers powerful ways to control how a webpage interacts with the browser, some of its uses have become less common due to advancements in web standards and best practices. Nonetheless, it remains an important tool in certain scenarios, especially for backward compatibility and specific client-side behavior control.
Syntax
<meta http-equiv="refresh | default-style | content-type | content-security-policy">
Values
- refreshSpecifies a time interval in seconds for the document to refresh.
- default-styleSpecifies the name of the default CSS set.
- content-typeSpecifies the media type, formerly MIME type, and character encoding of the page.
- content-security-policySpecifies the current page's content policy.
Applies To
The http-equiv
attribute can be used on the following html elements.
Example
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Browser Support
The following table will show you the current browser support for the HTML http-equiv
Attribute.
Desktop | |||||
![]() |
![]() |
![]() |
![]() |
![]() |
|
12 | 1 | 1 | 12.1 | 4 |
Tablets / Mobile | |||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
18 | 4 | 12.1 | 3.2 | 1 | 4.4 |
Last updated by CSSPortal on: 28th March 2024