W3Schools.com

Meta httpEquiv Property

Meta Object Reference Meta Object

Definition and Usage

The httpEquiv property sets or returns an HTTP header for the information in the content attribute.

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

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

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

Syntax

Set the httpEquiv property:

linkObject.httpEquiv="HTTP-header"

Return the httpEquiv property:

linkObject.httpEquiv

Some commonly used HTTP-header values are:

Value Description
cache-control Controls the caching mechanism to use for the document.

Available values:

  • public - cached in public shared caches
  • private - cached in private cache
  • no-cache - not cached
  • no-store - cached but not archived

Example:

<meta http-equiv="cache-control" content="no-cache" />

content-language Specifies the natural language(s) of the document (used by search engines to categorize pages by language).

Example:

<meta http-equiv="content-language" content="en-US" />

content-type Specifies the character set for the contents of the document.

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

Example:

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

date Specifies the date and time when the page was created.

Example:

<meta http-equiv="date" content="Wed, 16 Feb 2011 22:34:13 GMT" />

expires Specifies the date and time when the page will expire.

Example:

<meta http-equiv="expires" content="Fri, 30 Dec 2011 12:00:00 GMT" />

last-modified Specifies the last modification date.

Example:

<meta http-equiv="last-modified" content="Mon, 03 Jan 2011 17:45:57 GMT" />

location Redirects the visitor to another location.

Example:

<meta http-equiv="location" content="URL=http://www.w3schools.com" />

refresh Defines a time interval for the document to refresh itself.

Example:

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

set-cookie Creates a cookie with specified name,expires date and value.

Example:

<meta http-equiv="set-cookie" content="w3scookie=myContent;expires=Fri, 30 Dec 2011 12:00:00 GMT; path=http://www.w3schools.com">

window-target Specifies the name of the frame where the current document must be loaded


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The httpEquiv property is supported in all major browsers.


Example

Example

Display the HTTP header for the information in the content attribute:

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

<script type="text/javascript">
function displayResult()
{
var x=document.getElementsByTagName("meta")[0].httpEquiv;
alert(x);
}
</script>

</head>
<body>

<button type="button" onclick="displayResult()">Display HTTP-Equiv</button>

</body>
</html>

Try it yourself »


Meta Object Reference Meta Object
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE