Open In App

HTML referrerpolicy Attribute

The HTML referrerpolicy attribute is used to define an HTTP header control that specifies the amount of reference information that would be sent to the server when fetching out the result from the server. It is mainly used with following elements: <a>,<area>,<link>,<img>,<iframe>and <script> element. Referrer policy is used to maintain the security and privacy of source account while fetching resources or performing navigation. This is done by modifying the algorithm used to populate Referrer HeaderPlease refer to the HTTP headers | Referrer-Policy article for further details.

Supported Tags:



Syntax:

<element referrerpolicy="value">

Values: 



Example Code: Below code illustrates the use of referrerpolicy attribute in <iframe> element.  




<!DOCTYPE html>
<html>
  <head>
    <title>HTML referrerpolicy Attribute</title>
  </head>
 
  <body style="text-align: center">
    <h1>GeeksforGeeks</h1>
 
    <h2>HTML referrerpolicy Attribute</h2>
 
    <iframe
      height="200"
      width="400"
      referrerpolicy="no-referrer">
    </iframe>
  </body>
</html>

 
Output: In this case, the value of the referrerpolicy attribute is set to “no-referrer”, which means that the no-referrer information will be sent to the server along with the HTTP request. 

Example 2: Below code illustrates the use of referrerpolicy attribute in <a> tag.




<!DOCTYPE html>
<html>
  <head>
    <title>HTML referrerpolicy Attribute</title>
  </head>
 
  <body>
    <h2>GeeksForGeeks</h2>
    <h2>HTML referrerpolicy Attribute</h2>
     
<p>
      If you want to upgrade your coding skill then checkout the
      <a
        rel="noopener"
        referrerpolicy="unsafe-url">
        GeeksforGeeks Courses
      </a>
    </p>
 
 
  </body>
</html>

Output: In this case, we have used the referrerpolicy attribute in the anchor element, the value is set to “unsafe-url” that sends an origin path, and query string as a piece of reference information but does not include password and username.

Supported Browsers: The list of browsers supported by HTML Referrerpolicy Attribute are given below: 

 


Article Tags :