http-equiv

The http-equiv attribute in HTML allows a <meta> tag to convey HTTP header information, enabling the document to communicate settings to the browser.

http-equiv

The http-equiv attribute in HTML is used to provide HTTP header-like information directly within an HTML document. It acts as an HTTP equivalent and allows web pages to communicate settings to the browser without modifying server responses. This attribute is primarily applied within the <meta> tag, which is placed inside the <head> section of a webpage.

Syntax

index.html
<meta http-equiv="refresh | default-style | content-type | content-security-policy">

Example

My Website

Some text...

index.html
<h1>My Website</h1>  
<p>Some text...</p>

Attribute Values

ValueDescription
content-security-policyDefines security rules for the document. Example: <meta http-equiv="content-security-policy" content="default-src 'self'">
content-typeSpecifies the character encoding format for the document. Example: <meta http-equiv="content-type" content="text/html; charset=UTF-8">
default-styleDetermines the preferred stylesheet for the webpage. Example: <meta http-equiv="default-style" content="preferred-stylesheet-name"> Note: The value should match the title attribute of a corresponding <link> or <style> element.
refreshAutomatically refreshes or redirects the page after a specified time. Example: <meta http-equiv="refresh" content="300">
Excessive use of refresh can affect user experience and accessibility.

Applies To

The http-equiv attribute is specifically used with:

Conclusion

The http-equiv attribute provides a way for HTML documents to send metadata instructions to the browser, functioning similarly to HTTP headers. It is useful for managing security policies, defining content encoding, setting default styles, and controlling page refresh behavior. However, some values, such as refresh, should be applied carefully to maintain a seamless and user-friendly experience. Understanding its functionality helps developers configure web pages effectively for both performance and accessibility.