References

Beginner-friendly references for web development, with live, editable examples.

The HTML http-equiv attribute

Attribute All modern browsers Updated
Quick answer

The HTML http-equiv attribute creates a pragma directive that behaves like an HTTP response header. It is used on the <meta> element.

Overview

The http-equiv attribute defines an HTTP-header-like meta directive. It is used on document head elements like <meta>, <link> and <script>.

It belongs to the document head — metadata, stylesheet and script loading, encoding and resource hints. These attributes shape how the page is interpreted and how efficiently its resources load.

Syntax

<meta http-equiv="content-security-policy" content="default-src 'self'">

Values

Value
content-type | default-style | refresh | content-security-policy | x-ua-compatible

Best practices

  • Declare the character encoding with <meta charset="utf-8"> first in the <head>.
  • Load scripts with defer (or as modules) so they do not block parsing.
  • Protect third-party resources with integrity and crossorigin (Subresource Integrity).
  • Use resource hints like preload deliberately, paired with the right as value.

Frequently asked questions

What does the http-equiv attribute do?
Defines an HTTP-header-like meta directive.
Where do head attributes apply?
On the metadata elements in the <head><meta>, <link>, <script> and <base>.
What is the difference between async and defer?
async runs a script as soon as it loads in no set order; defer runs scripts in order after the document is parsed.
Which elements use the http-equiv attribute?
It is an element-specific attribute, used on document head elements like <meta>, <link> and <script>.