CodeBlanks Logo Icon CodeBlanks

Referrer policy

HTML course · Expert · Lesson 27/39

Control referrer with <meta name="referrer">.

What is a referrer?

When a page navigates to another, the browser sends a Referer header telling the destination where the user came from. This is called the referrer. Sometimes this info must be limited for privacy; for example, a user id may live in the URL.

In HTML, the meta name="referrer" tag tells the browser how much info to send. It sets a policy for the whole page.

meta name=referrer values

Common values for meta name="referrer":

  • no-referrer: send no info
  • same-origin: send only on same origin
  • strict-origin: send origin only; send nothing on HTTPS downgrade
  • strict-origin-when-cross-origin: full URL on same origin, origin only on cross-origin

The last value is the modern browser default as of 2026 and keeps a good balance.

Exercise Add the referrer policy meta tag

Take the previous lesson's page. Inside <head>, after the CSP meta, add a referrer policy meta tag:

  • name="referrer"
  • content="strict-origin-when-cross-origin"
Show example solution
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'">
    <meta name="referrer" content="strict-origin-when-cross-origin">
    <title>Secure Bank - Sign in</title>
  </head>
  <body>
    <h1>Secure Bank</h1>
    <p>Please sign in with your user code.</p>
    <p><a href="https://help.securebank.example/signing-in" target="_blank" rel="noopener noreferrer">Help center</a></p>
  </body>
</html>

Test yourself

  1. Which is the modern browser referrer default in 2026?

    • no-referrer
    • same-origin
    • unsafe-url
    • strict-origin-when-cross-origin
    Show answer

    strict-origin-when-cross-origin — Correct. This value sends the full URL on same origin and only the origin on cross-origin.

  2. Complete the default referrer value

    <meta name="referrer" content="____">
    Show answer
    <meta name="referrer" content="strict-origin-when-cross-origin">
  3. Match each referrer value to its meaning

    no-referrer
    send no info
    same-origin
    same origin only
    strict-origin
    origin only
    unsafe-url
    full URL (risky)

All lessons in Expert