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.
Fundamentals
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.
Foundation
📝 Syntax
Add http-equiv and content to a <meta> element inside <head>:
Encoding meta tags belong in <head>. The page renders normally when UTF-8 is set correctly.
Special characters display properly: café, naïve, 😊
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:
After 5 seconds the browser navigates to https://example.com. Screen readers may announce the redirect unexpectedly—prefer HTTP 301/302 redirects in production.
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><htmllang="en"><head><metacharset="UTF-8"><metahttp-equiv="cache-control"content="no-cache, no-store, must-revalidate"><metahttp-equiv="refresh"content="300;url=https://example.com"><title>Your HTML Page</title></head><body><!-- Your page content goes here --></body></html>
📤 Output:
charset="UTF-8" — sets document encoding
cache-control — hints browsers not to cache stale content
refresh with 300 — redirects after 300 seconds (5 minutes)
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
<metahttp-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>
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.
A11y
♿ 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.
Compatibility
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 ChromeFully supported
Full support
Mozilla FirefoxFully supported
Full support
Apple SafariFully supported
Full support
Microsoft EdgeFully supported
Full support
Internet ExplorerFully supported
Full support
OperaFully supported
Full support
http-equiv attribute99% supported
Bottom line: Supported for common values; prefer meta charset and server HTTP headers where possible.
Pro Tips
💡 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
Wrap Up
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.
Five truths every developer should know about http-equiv
Bookmark these before adding meta directives to your pages.
5
Core concepts
📄01
Meta Only
Used on <meta> tags.
Scope
🌐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.