http-equiv (HTML attribute)
| Depr. | Version |
|---|---|
| No | HTML 2 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ | CH2+ |
|---|---|---|---|---|
| Full | Full | Full | Full | Full |
Syntax
Description
You can apply many settings to
a web server in the form of HTTP response headers—information that’s sent
back with the response to any request made for a resource on that server.
However, not everyone has direct access to their web site’s server
configuration options; if this is the case, you can use the
meta element to simulate an HTTP response header. For
example, the character encoding may be set at the server, but many web
authoring packages include character encoding as a meta
element just in case this important information is not sent by the
server.
Typical uses for the http-equiv
attribute include managing cache control, page refreshes, and page content
safety ratings. If the http-equiv attribute is used
in the meta element, the name
attribute shouldn’t be used.
Note that supplying an HTTP equivalent
in a meta element is only effective if the server
doesn’t send the corresponding real header; you can’t override an HTTP
header with a meta element. So using this attribute is
only of value when the server doesn’t send that particular header, or when
there is no server involved—for instance, when you’re viewing a document
from the local file system.
Example
This
http-equiv attribute defines the character set for
the document:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Value
The value of
http-equiv varies depending on the way you use it.
It may contain any of the following values:
"Allow""Content-Encoding""Content-Language""Content-Length""Content-Type""Date""Expires""Last-Modified""Location""Refresh""Set-Cookie""WWW-Authenticate"
Note that "Refresh" is a nonstandard HTTP
header extension, the use of which is strongly advised against for
accessibility reasons: it takes the control of the page away from the
user. This is particularly annoying if the user is having to access the
page using a screen reader and the content isn’t read out completely
before the page refresh kicks in. Using this type of
meta attribute value will cause a failure against
checkpoints defined in the Web Content Accessibility Guidelines versions
1.0 and 2.0 (still in draft format at time of
writing).
Compatibility
| Internet Explorer | Firefox | Safari | Opera | Chrome | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 3.0 | 3.5 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full |
While
http-equiv is designed for containing HTTP header
information, it doesn’t have many applications except with the values of
"Content-Type" and "X-UA-Compatible"
(introduced in IE8 for handling standards compatibility; a good
explanation of this issue can be found in the A List Apart article, “Beyond DOCTYPE: Web Standards, Forward Compatibility,
and IE8”).