Meta httpEquiv Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Meta


The httpEquiv property sets or gets an HTTP header in the content attribute.

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

Some commonly used HTTP-header values are:

Value Description
content-type Sets the character set for the contents of the document. Example: <meta http-equiv="content-type" content="text/html; charset=UTF-8">
default-style Sets the preferred style sheet to use. Example: <meta http-equiv="default-style" content="the documents preferred stylesheet">
refresh Defines a time interval for the document to refresh itself. Example: <meta http-equiv="refresh" content="300">

Return Value

Type Description
String Information about the HTTP response message header

The following code shows how to return the HTTP header for the information in the content attribute:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<meta http-equiv="content-type" content="text/html">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {/* ww w .j  a v a 2s.  c om*/
    var x = document.getElementsByTagName("META")[0].httpEquiv;
    var y = document.getElementsByTagName("META")[0].content;
    document.getElementById("demo").innerHTML = x + " " + y;


Related Tutorials