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

ValueReferrer SentNotes
no-referrerNothingMaximum privacy. No Referer header sent at all.
no-referrer-when-downgradeFull URL on HTTPS→HTTPS, nothing on HTTPS→HTTPWas the old browser default. Protects against protocol downgrade only.
originOrigin only (e.g. https://example.com)Strips the path and query. Good balance of utility and privacy.
origin-when-cross-originFull URL for same-origin, origin only for cross-originKeeps internal analytics intact, protects paths from third parties.
same-originFull URL for same-origin, nothing for cross-originCross-origin requests get no referrer at all.
strict-originOrigin only on HTTPS→HTTPS, nothing on downgradeLike origin but also protects against protocol downgrade.
strict-origin-when-cross-originFull URL same-origin, origin cross-origin, nothing on downgradeBrowser default. The best general-purpose policy.
unsafe-urlFull 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:

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

  1. Per-element referrerpolicy attribute (highest priority)
  2. <meta name="referrer"> page-wide policy
  3. Referrer-Policy HTTP header
  4. Browser default (strict-origin-when-cross-origin)

Common Mistakes

  • Lazy-loading every page to no-referrer breaks analytics and affiliate attribution. Use a targeted approach instead.
  • Using unsafe-url sends 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.

See Also

  • integrity — verify that fetched resources have not been tampered with
  • <a> element reference
  • <img> element reference
  • <link> element reference