Meta httpEquiv Attribute

Definition and Usage

httpEquiv Sets or returns the HTTP header information in the HTML <meta> content attribute.

<meta> http-equiv attribute Can be used to simulate HTTP response headers.

The value of the http-equiv attribute depends on the value of the content attribute.

Note:If set name attributeIf so, the http-equiv attribute should not be set.

See also:

HTML Reference Manual:HTML <meta> Tag

Example

Example 1

Return the HTTP header information in the content attribute:

var x = document.getElementsByTagName("META")[0].httpEquiv;

Try it yourself

Example 2

Change the values of the http-equiv and content attributes. The following example will refresh the document every 30 seconds:

document.getElementsByTagName("META")[0].httpEquiv = "refresh";
document.getElementsByTagName("META")[0].content = "30";

Try it yourself

Syntax

Return the httpEquiv attribute:

metaObject.httpEquiv

Set the httpEquiv attribute:

metaObject.httpEquiv = HTTP-header
Some commonly used HTTP-header values are:

Attribute Value

Value Description
content-type

Specify the character set of the document content.

Tip:It is recommended to always specify the character set.

Example:

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

default-style

Specify the preferred stylesheet to be used.

Example:

<meta http-equiv="default-style" content="the documents preferred stylesheet">

Note:The value of the content attribute above must match the value of the title attribute of the link element in the same document, or it must match the value of the title attribute of the style element in the same document.

refresh

Define the time interval for the document to refresh itself.

Example:

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

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

Technical Details

Return Value: String, information about HTTP response message headers.

Browser Support

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

Related Pages

HTML Reference Manual:HTML <meta> http-equiv Attribute