HTML http-equiv Attribute

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Meta & Document Head

Introduction

The http-equiv attribute is a versatile feature in HTML that lets you instruct the browser as if certain HTTP response headers were sent with the page. It is used on <meta> tags in the document <head>, paired with the content attribute that holds the header value. Common uses include character encoding hints, timed page refresh, and caching directives—though many of these are better handled by real HTTP headers or modern HTML alternatives.

What You’ll Learn

01

meta Tags

Where http-equiv lives.

02

content-type

Legacy charset hint.

03

refresh

Reload or redirect.

04

cache-control

Caching hints.

05

meta charset

Modern alternative.

06

JavaScript

Update meta at runtime.

Purpose of http-equiv

The primary purpose of the http-equiv attribute is to provide document-level directives that mimic HTTP response headers. Instead of relying solely on the server, you can embed certain instructions directly in HTML so the browser knows how to interpret encoding, refresh timing, or caching behavior.

The name http-equiv means “HTTP equivalent.” Each <meta http-equiv="..." content="..."> pair tells the browser to behave as if it received a corresponding HTTP header—within the limits of what HTML meta tags can actually enforce.

💡
Real HTTP headers are stronger

Server-sent headers (via your web server or CDN) are the authoritative way to control caching, redirects, and security policies. Use http-equiv when you cannot set headers directly, but prefer proper HTTP configuration in production.

📝 Syntax

Add http-equiv and content to a <meta> element inside <head>:

http-equiv.html
<meta http-equiv="refresh" content="5;url=https://example.com">

Syntax Rules

  • Valid only on <meta> elements in the document <head> (early in the head when possible).
  • Always pair with a content attribute that defines the header value.
  • The http-equiv value names the simulated header (e.g. refresh, cache-control).
  • For character encoding in HTML5, prefer <meta charset="UTF-8"> over http-equiv="content-type".
  • Do not confuse http-equiv with name — they serve different meta purposes.

💎 Values

The http-equiv attribute supports several values, each simulating a different HTTP header:

content-type (legacy)

Specifies the document’s MIME type and character encoding. In HTML5, use <meta charset="UTF-8"> instead:

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

<!-- Modern (recommended) -->
<meta charset="UTF-8">

refresh

Reloads the page or redirects after a delay in seconds:

refresh.html
<!-- Reload after 5 seconds -->
<meta http-equiv="refresh" content="5">

<!-- Redirect after 5 seconds -->
<meta http-equiv="refresh" content="5;url=https://example.com">

cache-control

Suggests caching behavior to the browser. Less reliable than a real HTTP Cache-Control header from the server:

cache-control.html
<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate">

Other common values

  • http-equiv="X-UA-Compatible" content="IE=edge" — Legacy Internet Explorer document mode hint.
  • http-equiv="Content-Security-Policy" — Limited CSP via meta (prefer HTTP header when possible).
  • http-equiv="default-style" — Names the preferred alternate stylesheet.

⚡ Quick Reference

http-equiv Valuecontent ExamplePurpose
content-typetext/html; charset=UTF-8Legacy encoding (use charset instead)
refresh5;url=https://example.comRedirect after 5 seconds
cache-controlno-cache, no-storeDiscourage caching
X-UA-CompatibleIE=edgeLegacy IE mode
Element<meta>Only valid on meta tags
Modern charset<meta charset="UTF-8">Preferred over content-type

Applicable Elements

ElementSupported?Notes
<meta http-equiv content>YesPrimary and only standard use
<meta name content>Uses nameDifferent attribute—for description, viewport, etc.
<link>, <script>Nohttp-equiv is meta-specific

http-equiv vs name on <meta>

AttributeSimulates / DefinesExample
http-equivHTTP response header behavior<meta http-equiv="refresh" content="5">
nameDocument metadata by name<meta name="description" content="...">
charsetCharacter encoding (no content needed)<meta charset="UTF-8">

Examples Gallery

Character encoding, meta refresh, cache-control, combined head setup, and dynamic updates with JavaScript.

👀 Live Preview

Common http-equiv meta tags (these live in <head> and are not visible on the page):

http-equivcontentEffect
content-typetext/html; charset=UTF-8Legacy charset hint
refresh5;url=https://example.comRedirect after 5s
cache-controlno-cacheCaching hint

Meta tags configure browser behavior from HTML. Inspect the page source or DevTools Elements panel to see them.

Example — Character Encoding

Set UTF-8 encoding with the modern charset attribute (recommended) or the legacy http-equiv form:

charset.html
<head>
  <meta charset="UTF-8">
  <!-- Legacy equivalent: -->
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
Try It Yourself

How It Works

The browser reads the charset declaration early to decode bytes into characters. Place <meta charset="UTF-8"> within the first 1024 bytes of your HTML document for best results.

Example — Meta Refresh Redirect

Redirect users to another URL after a specified number of seconds:

refresh.html
<meta http-equiv="refresh" content="5;url=https://example.com">
Try It Yourself

How It Works

The browser parses content="5;url=https://example.com" as “wait 5 seconds, then go to this URL.” Omit url= to reload the current page instead. Avoid short delays that surprise users.

Example — Combined Head Setup

Let’s explore a practical example using multiple http-equiv directives in one document:

http-equiv.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate">
  <meta http-equiv="refresh" content="300;url=https://example.com">
  <title>Your HTML Page</title>
</head>
<body>
  <!-- Your page content goes here -->
</body>
</html>

How It Works

In this example, UTF-8 encoding is set with the modern charset attribute, caching is discouraged via cache-control, and the page redirects to Example.com after five minutes. Use each directive only when you truly need it.

Dynamic Values with JavaScript

You can dynamically update the content attribute of an http-equiv meta tag using JavaScript:

dynamic-http-equiv.html
<meta http-equiv="cache-control" content="no-cache">

<script>
  var meta = document.querySelector("meta[http-equiv='cache-control']");
  meta.content = "no-cache, no-store, must-revalidate";
</script>
Try It Yourself

How It Works

JavaScript changes the meta tag’s content property at runtime. Note that some directives (like charset) must be set before the parser reads the document—dynamic changes work best for tags that affect later behavior, not initial parsing.

♿ Accessibility

  • Avoid unexpected meta refresh — Auto-redirects can disorient screen reader users. Prefer HTTP redirects or explicit user actions (a link or button).
  • Give users time to read — If you must use refresh, use a long delay and provide visible notice about the upcoming redirect.
  • Do not rely on meta for critical security — CSP and cache policies belong in real HTTP headers configured on the server.
  • Set charset early — Correct encoding ensures assistive technologies and browsers display text accurately.

🧠 How http-equiv Works

1

Author adds meta in head

http-equiv + content pair.

Markup
2

Browser parses early head

Treats meta as HTTP-equivalent directive.

Parse
3

Browser applies behavior

Encoding, refresh timer, or cache hint.

Action
=

Document-level control

Browser behavior shaped from HTML when headers are unavailable.

Browser Support

Common http-equiv values like refresh and cache-control are widely supported. The legacy content-type form works but is superseded by <meta charset>. Real HTTP headers always take precedence when both are present.

HTML5 · Widely supported

Meta HTTP-equivalent directives

All major browsers honor common http-equiv values on <meta> elements in the document head.

99% Browser support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
Internet Explorer Fully supported
Full support
Opera Fully supported
Full support
http-equiv attribute 99% supported

Bottom line: Supported for common values; prefer meta charset and server HTTP headers where possible.

💡 Best Practices

✅ Do

  • Use <meta charset="UTF-8"> for character encoding
  • Understand each http-equiv value before using it
  • Set critical policies via real HTTP headers on the server
  • Test meta behavior across different browsers
  • Place important meta tags early in <head>

❌ Don’t

  • Rely on meta refresh for production redirects
  • Assume meta cache-control replaces server headers
  • Use http-equiv="content-type" in new HTML5 projects
  • Add conflicting meta and HTTP header directives
  • Change charset via JavaScript after the page starts parsing

Conclusion

The http-equiv attribute provides a valuable way to control browser behavior directly from your HTML document by simulating HTTP response headers. Values like refresh and cache-control remain useful in specific scenarios.

For character encoding, use <meta charset="UTF-8">. For redirects, caching, and security policies, configure real HTTP headers on your server whenever you can. That gives you stronger, more predictable control over performance and user experience.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about http-equiv

Bookmark these before adding meta directives to your pages.

5
Core concepts
🌐 02

HTTP Equivalent

Simulates headers

Purpose
🔄 03

refresh

Reload or redirect

Values
04

meta charset

Modern encoding

Best practice
🔒 05

Server Headers

Authoritative control

Production

❓ Frequently Asked Questions

It simulates an HTTP response header on a <meta> tag. The browser uses the paired content value to control encoding hints, refresh timing, caching, and other document behavior.
The <meta> element in the document <head>. It is not used on visible elements like <div> or <img>.
Use <meta charset="UTF-8"> in HTML5. The http-equiv="content-type" form is legacy and unnecessary in modern documents.
content="5" reloads after 5 seconds. content="5;url=https://example.com" redirects after 5 seconds. Prefer HTTP 301/302 redirects for production sites.
No. Server-sent Cache-Control headers are authoritative and apply before HTML is parsed. Meta tags are a fallback hint with limited enforcement.
You update the content attribute: meta.content = "new value". Some directives must be present before parsing begins to take full effect.

Configure your document head correctly

Practice http-equiv meta tags and the modern charset alternative in the Try It editor.

Try charset example →

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.

5 people found this page helpful