X-Frame-Options Header Explained

What the HTTP X-Frame-Options header does and when it's used.

Published October 16, 2026

X-Frame-Options controls whether a page may be shown inside a frame or iframe, defending against clickjacking. Values: DENY or SAMEORIGIN.

How it works

CSP frame-ancestors is the modern replacement.

The X-Frame-Options header is part of the HTTP message and is case-insensitive in name.

In a real exchange

curl -i https://example.com/
X-Frame-Options: DENY
Where X-Frame-Options appears.

Practical examples

The header

X-Frame-Options: DENY

Set or use it in code

add_header X-Frame-Options "SAMEORIGIN" always;

Inspect it

curl -sI https://example.com | grep -i 'x-frame-options'

Common mistakes

  • Using the obsolete ALLOW-FROM
  • Forgetting it for authenticated pages
  • Not adding frame-ancestors in CSP

Key takeaways

  • X-Frame-Options: X-Frame-Options controls whether a page may be shown inside a frame or iframe, defending against clickjacking.
  • Check it in browser DevTools → Network.
  • Test with curl -I before deploying.

FAQ

Still needed?

Keep it for older browsers alongside frame-ancestors.

Is X-Frame-Options case sensitive?

Header names are case-insensitive; values may not be.

More HTTP articles