referrerpolicy
Controls how much referrer information is sent with requests. Prevents leaking URL paths to third parties.
Overview
The referrerpolicy attribute controls how much referrer information the browser sends when making requests for a resource or following a link. By default, browsers send the full URL of the current page in the Referer header, which can leak sensitive URL paths (user IDs, search queries, internal routes) to third parties.
You can set the policy per-element or page-wide using a <meta> tag. Per-element policies override the page-wide policy.
Policy Values
| Value | Referrer Sent | Notes |
|---|---|---|
no-referrer | Nothing | Maximum privacy. No Referer header sent at all. |
no-referrer-when-downgrade | Full URL on HTTPS→HTTPS, nothing on HTTPS→HTTP | Was the old browser default. Protects against protocol downgrade only. |
origin | Origin only (e.g. https://example.com) | Strips the path and query. Good balance of utility and privacy. |
origin-when-cross-origin | Full URL for same-origin, origin only for cross-origin | Keeps internal analytics intact, protects paths from third parties. |
same-origin | Full URL for same-origin, nothing for cross-origin | Cross-origin requests get no referrer at all. |
strict-origin | Origin only on HTTPS→HTTPS, nothing on downgrade | Like origin but also protects against protocol downgrade. |
strict-origin-when-cross-origin | Full URL same-origin, origin cross-origin, nothing on downgrade | Browser default. The best general-purpose policy. |
unsafe-url | Full URL always (including to HTTP) | Not recommended. Exposes the full URL path to all destinations. |
Which Policy to Use
Sensible Default
For most sites, strict-origin-when-cross-origin is the right choice. It is the browser default and provides a good balance: your own analytics see full URLs, third parties see only the origin, and nothing is sent on protocol downgrade.
Maximum Privacy
Use no-referrer on individual elements that load resources from untrusted third parties, or when the current page URL contains sensitive information (user tokens, internal paths).
Analytics-Friendly
Use origin-when-cross-origin if partner sites need to know your origin for attribution but should not see the full URL path.
Applies To
The referrerpolicy attribute works on elements that make network requests:
<a>— navigation links<img>— image loads<iframe>— embedded documents<script>— script loads<link>— stylesheets, preloads, etc.
Per-Element Policy
Privacy-Sensitive Image Loads
Third-party images (avatars, CDN assets, tracking pixels) should not receive your full page URL.
Links
Control what information partner sites or external tools see about your pages.
Iframes
Embedded third-party content should generally receive minimal referrer information.
Scripts and Stylesheets
CDN resources rarely need referrer information at all.
Page-Wide Policy
Set a default policy for the entire page using a <meta> tag. Individual elements can still override it with their own referrerpolicy attribute.
Policy Resolution Order
- Per-element
referrerpolicyattribute (highest priority) <meta name="referrer">page-wide policyReferrer-PolicyHTTP header- Browser default (
strict-origin-when-cross-origin)
Common Mistakes
- Lazy-loading every page to
no-referrerbreaks analytics and affiliate attribution. Use a targeted approach instead. - Using
unsafe-urlsends the full URL including query strings, even over HTTP. Avoid unless you have a specific need and trust the destination. - Forgetting protocol downgrade: Policies without "strict" in the name may still send referrers on HTTPS-to-HTTP requests. Prefer
strict-*variants.