Glossary / X-Frame-Options
What is X-Frame-Options
X-Frame-Options is an HTTP header that tells the browser whether your page may be shown inside an <iframe> on another site. It protects against clickjacking, where an attacker embeds your site in a transparent frame and tricks the user into clicking buttons they cannot see.
Check your site
The header has two working values. DENY forbids showing the page in a frame anywhere. SAMEORIGIN allows framing only by pages from the same domain, which suits sites that embed their own pages.
Without this protection an attacker can load your site in an invisible iframe on top of a bait page. The user thinks they are clicking "Claim your prize", but the click lands on a button on your site and confirms a payment or changes a setting.
X-Frame-Options is an old, simple mechanism that every browser still supports. Modern projects often back it with the frame-ancestors directive in Content-Security-Policy, which is more flexible and can list specific allowed domains.
Example
X-Frame-Options: SAMEORIGIN
Common mistakes
- Using the obsolete ALLOW-FROM value. Most browsers ignore it; for a list of domains use frame-ancestors in CSP.
- Setting DENY and then wondering why your own widget or page preview no longer loads in a frame. That case needs SAMEORIGIN.
- Expecting the header to protect against XSS. It only stops clickjacking, that is, framing of your page.
- Putting it in an HTML <meta> tag. X-Frame-Options works only as an HTTP response header and has no effect in meta.