http-equiv
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
<meta http-equiv="refresh | default-style | content-type | content-security-policy">
Example
Some text...
<h1>My Website</h1>
<p>Some text...</p>
Attribute Values
Value | Description |
---|---|
content-security-policy | Defines security rules for the document. Example: <meta http-equiv="content-security-policy" content="default-src 'self'"> |
content-type | Specifies the character encoding format for the document. Example: <meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
default-style | Determines 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. |
refresh | Automatically refreshes or redirects the page after a specified time. Example: <meta http-equiv="refresh" content="300"> |
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.
hreflang
The hreflang attribute indicates the language and regional targeting of a linked document, helping search engines provide relevant content to users.
id
The id attribute in HTML provides a unique identifier for an element, enabling specific styling and scripting, while ensuring that each ID is unique within a page.