HTML <meta> http-equiv Attribute

Definition and Usage

http-equiv Attribute content attribute The value provides HTTP headers.

http-equiv The attribute can be used to simulate HTTP response headers.

Example

Refresh the document every 30 seconds:

<head>
  <meta http-equiv="refresh" content="30">
</head>

Try it yourself

Syntax

<meta http-equiv="content-security-policy|content-type|default-style|refresh">

Description

Rewriting the value of the HTTP (Hypertext Transfer Protocol) header fields is one of the uses of the meta element. HTTP is generally used for transmitting HTML data between the server and the browser. Each response from the server contains a set of fields that inform the browser about its content. The meta element can be used to simulate four of these header fields.

http-equiv The purpose of the attribute is to specify the name of the header field to be simulated, and the field value is provided by content attribute Specify.

http-equiv There are four available values for the attribute, as shown in the following table:

Attribute value

Value Description
content-security-policy

Specify the content policy of the document.

For example:

<meta http-equiv="content-security-policy" content="default-src 'self'">

content-type

Specify the character encoding of the document.

Tip:This is another way to declare the character encoding of an HTML page.

For example:

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

default-style

Specify the preferred stylesheet to be used.

For example:

<meta http-equiv="default-style" content="the document's preferred stylesheet">

Note:The corresponding content attribute value should be the same as the title attribute value of some style element or link element in the same document.

refresh

Define the time interval for the document to refresh itself, in seconds.

For example:

<meta http-equiv="refresh" content="300">

You can also specify another URL for the browser to load:

For example:

<meta http-equiv="refresh" content="5; https://www.codew3c.com">

Note:Use the "refresh" value with caution, as it can take away the user's control over the page. Using "refresh" will cause the W3C's Web Content Accessibility Guidelines to fail.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support