The HTML referrerpolicy attribute
In short
The HTML referrerpolicy attribute controls how much referrer information is sent when fetching the resource or following the link. It is used on the <a>, <area>, <img>, <iframe>, <link> and <script> elements.
Overview
The referrerpolicy attribute controls how much referrer information is sent when fetching the resource or following the link. It applies to the <a>, <area>, <img>, <iframe>, <link> and <script> elements.
Use it to limit how much of your URL is leaked to third parties; no-referrer or strict-origin-when-cross-origin are common privacy-preserving choices.
Syntax
<img src="pic.jpg" referrerpolicy="no-referrer">
Values
| Value |
|---|
| no-referrer | no-referrer-when-downgrade | origin | origin-when-cross-origin | same-origin | strict-origin | strict-origin-when-cross-origin (default) | unsafe-url |
Best practices
- Write descriptive link text. Avoid "click here", which is meaningless out of context.
- When using
target="_blank", modern browsers addrel="noopener"for you, but set it explicitly for older ones. - Use rel values like
nofollowandnoreferrerdeliberately, for SEO and privacy. - Make sure links are distinguishable by more than color alone.
Frequently asked questions
What does the referrerpolicy attribute do?
Controls the Referer header sent for the request.
What values does the referrerpolicy attribute take?
One of
no-referrer, no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin and unsafe-url. With no value, the browser uses its default, which is strict-origin-when-cross-origin in current browsers.How is referrerpolicy different from rel="noreferrer"?
rel="noreferrer" removes the Referer header and also implies noopener. referrerpolicy only controls the header, and it can send part of the URL instead of nothing.






















