HTML referrerpolicy Attribute

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The referrerpolicy attribute controls how much referrer data the browser sends in the HTTP Referer header when that element navigates or fetches a resource. Use it on <a>, <area>, <img>, <iframe>, <link>, and <script>.

Default (when omitted/invalid): strict-origin-when-cross-origin. Page-wide alternatives: HTTP Referrer-Policy header or <meta name="referrer">. Related: rel="noreferrer" (no dash).

Baseline · Widely available.

Not deprecated. Note the spelling split: header Referer is misspelled; attribute/policy names use referrer.

Avoid unsafe-url unless you truly need it.

It can leak full HTTPS paths (and queries) to any destination, including HTTP. Prefer stricter policies for privacy.

HTML Syntax

syntax.html
<a href="…" referrerpolicy=" policy">
<img src="…" referrerpolicy=" policy">

In JavaScript: element.referrerPolicy = "no-referrer" (capital P in the IDL property).

Attribute Values

Common policies (from page https://example.com/page?q=1):

ValueWhat gets sent (summary)Try it
no-referrerNo Referer headerTry it
originOnly https://example.com/Try it
same-originFull URL same-origin; none cross-originTry it
strict-origin-when-cross-originDefault: full same-origin; origin cross-HTTPS; none on downgradeTry it
unsafe-urlFull URL almost always — leaks pathsTry it

Also: no-referrer-when-downgrade, origin-when-cross-origin, strict-origin. Empty/invalid falls back to the default.

Live Preview

Pick a policy. The log shows what Referer would look like for three sample destinations (study model — open DevTools Network to verify real requests).

Policy

From document: https://example.com/page?q=1

Sample Referer

HTML Examples

Short demos. Inspect Network → request headers after following a link or loading an image.

Example 2 — Referrer on Image Requests

Limit what third-party image hosts learn about your page.

HTML
<img src="/images/javascript.png"
     alt="Demo image"
     width="128" height="128"
     referrerpolicy="origin">
<p>Cross-origin hosts would see only your origin, not the full path.</p>
Try It Yourself

How It Works

  1. img supports referrerpolicy on its request.
  2. origin sends scheme + host + port only.
  3. Path/query stay off the Referer header.
  4. Useful for hotlinked or analytics-sensitive CDNs.

Example 3 — referrerpolicy vs rel="noreferrer"

Both can suppress referrers; noreferrer also affects opener behavior.

HTML
<p>
  <a href="https://example.com/" referrerpolicy="no-referrer">
    Policy attribute
  </a>
</p>
<p>
  <a href="https://example.com/" rel="noreferrer">
    rel=noreferrer (no dash)
  </a>
</p>
Try It Yourself

How It Works

  1. referrerpolicy picks among many policies.
  2. rel="noreferrer" forces no referrer for that link.
  3. Spelling: link type has no dash; meta/HTTP use referrer.
  4. Prefer the attribute when you need origin or the default strict policy.

Edge Cases & Pitfalls

Privacy bugs usually come from oversharing paths or mixing up spellings.

default

Default is already fairly strict

strict-origin-when-cross-origin strips paths on cross-origin HTTPS and blocks HTTPS→HTTP referrers.

leak

Skip unsafe-url by default

Full URLs can include private path segments and query tokens.

meta

Document policy vs element policy

HTTP header / <meta name="referrer"> set the baseline; element referrerpolicy applies to that fetch/navigation.

list

Comma-separated fallbacks are HTTP-only

Multiple policies in one header work for negotiation; the HTML attribute takes a single token.

spell

Referer vs referrer

The request header keeps the historical misspelling; attributes and policies use “referrer”.

Browser Support

referrerpolicy is an HTML attribute implementing Referrer Policy on links and resource elements. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

referrerpolicy

Supported in modern browsers on a, area, img, iframe, link, and script. Prefer strict policies; treat unsafe-url as an exception.

96% Global support (approx.)
Google Chrome Yes
Full support
Mozilla Firefox Yes
Full support
Apple Safari Yes
Full support
Microsoft Edge Yes
Full support
Opera Yes
Full support
Samsung Internet Yes
Full support
Internet Explorer No
Not supported
referrerpolicy Widely supported

Bottom line: Safe to use for privacy-minded links and embeds. Start from the default or no-referrer/origin when you need less sharing.

Key Takeaways

  • Role: control Referer for that element’s request.
  • Default: strict-origin-when-cross-origin.
  • Works on a, area, img, iframe, link, script.
  • Avoid unsafe-url for everyday use.

One line: referrerpolicy decides how much of your URL other sites see when users follow that link or load that resource.

Frequently Asked Questions

It sets how much referrer information the browser sends in the Referer header when following a link or fetching a resource from that element (a, area, img, iframe, link, script).
strict-origin-when-cross-origin: full URL for same-origin requests, origin only for secure cross-origin requests, and no referrer when downgrading HTTPS to HTTP.
rel="noreferrer" (no dash) forces no-referrer for that link and also implies noopener behavior for window.opener. referrerpolicy is the dedicated policy attribute with more options.
Yes. Use a Referrer-Policy HTTP header, or <meta name="referrer" content="…">. Element referrerpolicy overrides for that request.
Usually no. It can send full HTTPS paths (and query strings) even to insecure destinations. Prefer stricter policies.
No. It is Baseline widely available and the HTML way to set per-element Referrer Policy.

Next: rel

Describe the relationship of a linked resource (noopener, stylesheet, and more).

rel tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful