HTML http-equiv Attribute

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The http-equiv attribute on a <meta> element gives the browser a pragma — a document-level processing instruction similar to certain HTTP response headers. The matching value goes in content.

Only a subset of headers is supported (for example content-type, refresh, and content-security-policy). Prefer <meta charset> for encoding and real HTTP headers for production redirects and most security policies.

Baseline · Widely available.

Not experimental. The attribute itself is standard; some pragma names are obsolete or ignored (see values below).

Deprecated / ignored pragmas.

content-language is deprecated (use lang). set-cookie and x-ua-compatible are ignored by modern browsers.

Accessibility — meta refresh.

Short refresh intervals can interrupt screen reader users before they finish the page. Prefer server redirects, and keep any delay long enough to read.

HTML Syntax

syntax.html
<meta http-equiv=" pragma-name" content="value">

Place the tag in <head>. pragma-name selects the instruction; content supplies its parameters.

Attribute Values

Supported and notable pragma names (case-insensitive in practice):

ValueDescriptionTry it
content-typeMIME type + charset; prefer <meta charset>Try it
refreshReload or redirect after N secondsTry it
content-security-policyDeclare a CSP for the pageTry it
default-styleName of the preferred style sheet setTry it
content-languageDeprecated — use the lang attribute—
set-cookie / x-ua-compatibleIgnored by modern browsers—

Live Preview

Pick a pragma to preview the matching <meta> markup. This demo does not apply refresh or CSP to the tutorial page.

Shows sample markup only — safe to explore on this page.

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

Prefer <meta charset="utf-8"> for new pages.

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Encoding: Modern vs content-type

Use charset today. The http-equiv form is the older equivalent.

HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <!-- Preferred -->
  <meta charset="utf-8">

  <!-- Legacy equivalent (HTML documents only) -->
  <!--
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  -->

  <title>Encoding demo</title>
</head>
<body>
  <p>Hello, world.</p>
</body>
</html>
Try It Yourself

How It Works

  1. Preferred form. <meta charset="utf-8"> is short and clear.
  2. Legacy form. http-equiv="content-type" with content="text/html; charset=utf-8" does the same job in HTML.
  3. Early in head. Put encoding meta as early as possible so the browser parses text correctly.
  4. HTML only. The content-type pragma is for text/html documents, not XML/XHTML served as XML.

Example 2 — refresh Redirect

Reload or send the user to another URL after a delay. Prefer HTTP redirects in production.

HTML
<head>
  <meta charset="utf-8">
  <!-- Reloads after 300 seconds -->
  <meta http-equiv="refresh" content="300">

  <!-- Or redirect after 30 seconds -->
  <!--
  <meta http-equiv="refresh" content="30;url=https://example.com/">
  -->
  <title>Refresh demo</title>
</head>
Try It Yourself

How It Works

  1. Seconds only. content="300" reloads after 300 seconds from full page load.
  2. Redirect form. content="30;url=https://example.com/" navigates after 30 seconds.
  3. Timer start. The countdown begins after load and pageshow.
  4. Accessibility. Avoid short intervals; announce redirects when you must use them.

Example 3 — Content Security Policy

Declare a basic CSP with http-equiv. HTTP headers are still preferred for production.

HTML
<head>
  <meta charset="utf-8">
  <meta
    http-equiv="Content-Security-Policy"
    content="default-src 'self'">
  <title>CSP demo</title>
</head>
Try It Yourself

How It Works

  1. Name the pragma. Content-Security-Policy enables a page-level CSP.
  2. Policy in content. default-src 'self' limits default resource loading to the same origin.
  3. Test carefully. Strict policies can break inline scripts and third-party assets.
  4. Production tip. Deliver CSP via the HTTP header when you can; do not invent other security headers through http-equiv.

Edge Cases & Pitfalls

Unrecognized pragmas are ignored — which can create a false sense of security.

security

Do not invent security headers in meta

MDN: do not set other security headers with <meta http-equiv>. Unsupported names are ignored.

deprecated

content-language is deprecated

Use the document lang attribute instead of a language pragma.

ignored

set-cookie and x-ua-compatible

Modern browsers ignore these pragmas. Use HTTP Set-Cookie and drop IE compatibility metas.

a11y

Refresh can trap users

Auto-reload or redirect too quickly fails WCAG timing expectations. Prefer links and server redirects.

charset

Prefer <meta charset>

Shorter, clearer, and equivalent for HTML. Keep content-type only when maintaining old documents.

Browser Support

http-equiv is an HTML attribute on meta in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

http-equiv

Widely available since about July 2015. Individual pragmas differ: content-type, refresh, and CSP are useful; set-cookie and x-ua-compatible are ignored.

97% Global support (attribute)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer Supported (legacy pragmas)
Supported
http-equiv Widely supported

Bottom line: Safe to use for documented pragmas. Prefer charset meta, HTTP redirects, and HTTP security headers when possible.

Key Takeaways

  • Role: pragma on <meta> with a content value.
  • Common: content-type, refresh, content-security-policy.
  • Prefer: <meta charset> and HTTP redirects/headers when you can.
  • Avoid: short refresh, ignored pragmas, fake security metas.

One line: http-equiv is a limited meta pragma list — not a full HTTP header API.

Frequently Asked Questions

On a meta element, http-equiv names a pragma (processing instruction) as if certain HTTP headers applied to the document. The content attribute holds the matching value.
Only the meta element in the document head. Pair it with content for the pragma value.
Prefer <meta charset="utf-8">. The legacy form is <meta http-equiv="content-type" content="text/html; charset=utf-8">, which is equivalent but longer.
Use with care. Short refresh intervals hurt accessibility. Prefer HTTP redirects (3xx) for real redirects, and give users enough time if you must refresh.
No. Only a subset is supported (such as content-type, refresh, and content-security-policy). Unrecognized values are ignored. Do not rely on meta for other security headers.
No. Browsers ignore set-cookie pragmas, and x-ua-compatible is obsolete for modern browsers. Use real HTTP headers or modern markup instead.

Next: id

Give elements unique identifiers for links, labels, and scripts.

id tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful