Table of contents
Hi
If you write code, it is a high chance that you have used this attribute. Frequently it is omitted when writing code.
Today we will analyze its importance, limitations, where and how it should be used.
### HTTP-EQUIV
HTTP-EQIV is an attribute that defines the pragma directive. It is considered a content language. A content language is a type of language used to describe the language(s) intended for the audience so users can differentiate it according to their own preferred language.
Most are used within the Meta element to define definite settings that would otherwise require the use of an HTTP response header. Written as
meta http-equiv="X-UA-Compatible" content="IE=edge
USES
- To Simulate an HTTP response header.
- Provide header information or value of the content Attribute.
- It is important to note that the HTTP-Equiv attribute is accustomed within a meta element.
HOW TO USE HTTP-EQUIV
There are a few ways to use the HTTP-Equiv attribute.
They include:-
- **Content-type
- Refresh
- Content-security-policy
- Content-length
- Content-encoding
- Default-style
- Window-target**
The most prominent ones are Content-type and Refresh.
HTTP-EQIV USE IN DETAILS
Content-type specifies the character encoding for the document. This was much more widely used in HTML4 and written as
meta HTTP-equiv="content-type" content="text/html; charset=UTF-8"
However, the majority of the web uses HTML5; the use of content-type is obsolete presently.
To define the character encoding of document use:
<meta charset="UTF-8">
Content-security-policy
The content-security-policy value ensures that the sources defined are approved for the browser to load. For a prime.com domain, every resource loaded from the current domain would be finalized for load at any subdomain of prime.com.
<meta http-equiv="content-security-policy" content="default-src 'self' *.prime.com">
Content-Encoding
Content-encoding defines additional content-encoding for the document.
meta http-equiv=content-type – document character-encoding declaration
Content length
It defines the size of the document (in bytes).
Its Syntax:-Content-Length: <length>
Default-style
The default-style value specifies what the preferred style sheet to use is. The benefit of the content attribute must match the value of an element in the same document for this to be valid. It is written as
<meta http-equiv="default-style" content="/style.css">
Refresh:-With the refresh value, define a period to reload the document. For instance, if a document time period is coded to refresh 20 as
meta http-equiv="refresh" content="20"
the document would be set to refresh every 20 seconds.
Window-target
The http-equiv=”window-target” specifies the “named window” of the current page.
The primary use is to prevent a page from appearing inside another framed page: meta http-equiv=”window-target” content=”_bottom”
.
It means that the web browser will force the page to go to the bottom frameset.
CONCLUSION
The http-equiv, also known as an HTTP response header equivalent can be useful to access an origin server's configuration files that still need to make certain modifications. It is important to note that the http-equiv attribute does not take precedence or override HTTP response headers and is supported by the most popular browsers. Different values that used to be valid, such as set-cookie and content language, are now obsolete with http-equiv. Before using an http-equiv value, ensure you research whether or not there is a better way to implement what you are trying to achieve, as with the content-type character encoding example above.
Therefore, adding the http-equiv attribute to your HTML document is only beneficial if the HTTP response header is not already directed via the origin server.
Sources:-Content Language