X-Frame-Options is an HTTP response header that tells a browser whether it may render your page inside a frame or iframe. Set it to DENY or SAMEORIGIN and other sites cannot wrap your page in a hidden frame to trick visitors into clicking. Pair it with a Content-Security-Policy frame-ancestors directive, which replaces it in modern browsers, then check the live response headers to confirm both arrive. Our Response Headers Inspector shows exactly what your server sends.
TL;DR
- X-Frame-Options has two working values:
DENY(no framing at all) andSAMEORIGIN(only your own origin may frame the page).ALLOW-FROMis obsolete and browsers ignore it. - It must be sent as an HTTP header. A meta tag does nothing, per RFC 7034.
- When both headers are present, browsers that support
frame-ancestorsignore X-Frame-Options, so set both for coverage. - To allow specific partner sites, use
frame-ancestorsonly. X-Frame-Options cannot list several origins. - Verify with
curl -Ior a header inspector after every deploy.
Table of Contents
- What the header protects against
- The values you can use
- How to set X-Frame-Options
- Verify what the browser actually receives
- X-Frame-Options vs CSP frame-ancestors
- When a legitimate embed is blocked
- Related headers: CORP, COEP and CORS
- A related risk: the Host header
- Where we stand
- Check your headers now
- FAQ
- Sources
What the header protects against
Clickjacking works like this: an attacker loads your page in an invisible iframe on their own site, then lays a decoy button over it. The visitor thinks they are clicking the decoy, but the click lands on your page, perhaps on a "delete account" or "approve payment" button. The OWASP Clickjacking Defense Cheat Sheet lists the header-based defenses (X-Frame-Options and CSP frame-ancestors), the SameSite cookie attribute and JavaScript frame-busters, and recommends more than one for defense in depth.

The header is cheap. Chrome's web guidance describes clickjacking protection as easy to deploy with very low risk of breaking legitimate functionality. Mozilla's guidelines go further and call it mandatory for new websites.
One limit worth knowing: OWASP notes the header gives no benefit on responses with nothing to interact with, such as redirects or JSON API responses, per its HTTP Headers Cheat Sheet. Put your effort on HTML pages that carry forms, buttons and logged-in actions.
The values you can use
| Value | Meaning | Use it when |
|---|---|---|
DENY | The page cannot load in any frame, whatever the parent's origin | The page is never embedded |
SAMEORIGIN | Framing allowed only when the ancestor frames share the page's origin | Your own app frames its own pages |
ALLOW-FROM origin | Obsolete, ignored by modern browsers | Never |
The definitions come from MDN and match Chrome's Lighthouse documentation. If you still have an ALLOW-FROM line in a config, treat it as unprotected: the browser skips the header, so the page is frameable by anyone.
The header also takes a single value. You cannot send a list of domains. That is the main reason it was superseded.
How to set X-Frame-Options
Pick the layer that owns the response and set the header there. MDN gives examples for Apache, Nginx, IIS, HAProxy and Express in its X-Frame-Options reference. The common shapes:
Nginx
add_header X-Frame-Options "SAMEORIGIN" always;
Apache
Header always set X-Frame-Options "SAMEORIGIN"
Express (Node.js)
app.use((req, res, next) => {
res.setHeader('X-Frame-Options', 'DENY');
next();
});
Flask
@app.after_request
def add_headers(response):
response.headers['X-Frame-Options'] = 'SAMEORIGIN'
return response
The Flask pattern appears in Arul John's header guide. Platforms often have their own switch: Adobe Commerce, for instance, sets x-frame-options to SAMEORIGIN by default in app/etc/env.php and needs a redeploy after changes, per its clickjacking documentation.
Where it goes wrong
- Meta tag. Putting
<meta http-equiv="X-Frame-Options">in your HTML does nothing. RFC 7034 says the header is ignored there. - Nginx inheritance.
add_headerin alocationblock replaces headers set at theserverlevel. Usealwaysso error pages carry it too, and check each location. - Proxies and CDNs. A header set on the origin can be stripped or duplicated at the edge. Test the public URL, not the origin.
- Duplicate values. Two conflicting X-Frame-Options lines can cause browsers to drop the policy. Set it in one place.
Verify what the browser actually receives
Reading config is not proof. Check the response:
curl -sI https://example.com | grep -i x-frame
It prints the header or nothing at all if it is unset. For a quicker view of every cache and security header on a page, paste the URL into the Response Headers Inspector. It is free and needs no installation or account. Our guide to reading HTTP headers walks through the output, and the security headers checklist gives an order for the rest.
If you want the check on a schedule rather than by hand, the Website Uptime Monitor watches availability, and the Pingfloat Public API is there for scripting.
X-Frame-Options vs CSP frame-ancestors
frame-ancestors is a Content-Security-Policy directive that does the same job with more control. The differences that matter:
- It can authorize multiple domains, where X-Frame-Options takes one value.
- It checks the whole ancestor chain. RFC 7034 warns that X-Frame-Options implementations evaluate
SAMEORIGINagainst the top-level context, which leaves a nested-framing gap. - It works only as a header, like X-Frame-Options.
- When it is enforced, the CSP spec says X-Frame-Options must be ignored. The OWASP Secure Headers Project says the same.
Policy tiers
Chrome's guidance suggests matching the policy to how the page is really used:
| Situation | Send |
|---|---|
| Never embedded | Content-Security-Policy: frame-ancestors 'none' plus X-Frame-Options: DENY |
| Embedded only by your own site | frame-ancestors 'self' plus X-Frame-Options: SAMEORIGIN |
| Embedded by named partners | frame-ancestors 'self' https://trusted-partner.com and no X-Frame-Options |
The partner row drops X-Frame-Options on purpose: it cannot express a cross-origin allowlist, and DENY or SAMEORIGIN would block the embed in clients that evaluate it. See Chrome's security guidance.
Syntax details from OWASP: single quotes are required around 'self' and 'none' but not around hosts, and a wildcard like https://*.somesite.com matches subdomains, not the bare domain. Our Content Security Policy guide covers building, testing and enforcing the rest of the policy.
When a legitimate embed is blocked
If your own widget or dashboard refuses to load in an iframe, the console reports a refused-to-display error and the cause is the framed page's headers. Fix it on the page being framed:
- Inspect the response headers of the framed URL.
- If it sends
DENY, orSAMEORIGINwhile the parent is another origin, decide whether the page should be embeddable at all. - If it should, move to
frame-ancestorswith the exact parent origins and remove X-Frame-Options from that route. - Redeploy and re-check the headers, including at the CDN.
Keep the policy tight: only routes designed as embeddable widgets should omit both headers. Also give each iframe a title for accessibility; see our reference on iframes missing a title attribute.
Related headers: CORP, COEP and CORS
These are often confused with framing controls, but they govern different things.
- CORS relaxes the browser's rule against scripts reading cross-origin responses. It is not authentication and not a firewall. See our guide to CORS headers and how to add them.
- Cross-Origin-Resource-Policy (CORP) is sent by a resource to say who may load it in no-cors mode:
same-origin,same-siteorcross-origin, per MDN. MDN recommends the most restrictive value that works. - Cross-Origin-Embedder-Policy (COEP) is sent by a document. With
require-corp, it loads cross-origin subresources only if they send a compatible CORP header or are fetched with CORS, per MDN.
So CORP is the resource-side cousin of X-Frame-Options, and COEP is the embedder-side check. web.dev lists X-Frame-Options and CORP together among headers for all sites. You only need to coordinate them when you enable COEP for cross-origin isolation.
A related risk: the Host header
Host header injection is a separate problem, though it lives in the same request-header territory. Servers pick a virtual host from the Host header, and without validation an attacker can trigger redirects to their own domain, cache poisoning or poisoned password-reset links. The OWASP Web Security Testing Guide notes that X-Forwarded-Host can bypass checks that only look at Host. Validate both against an allowlist of your own domains.
Where we stand
Security headers fail quietly. Nothing breaks when X-Frame-Options is missing, so it stays missing until someone builds a clickjacking page against you.
We built Pingfloat as a free set of web tools so that checking a header, a certificate or a redirect takes seconds, with no install and no account for the core tools. Our view: set the header, then look at what the server really returns, every time you change the stack. Proxies, CDNs and framework defaults rewrite headers more often than people expect.
Run the check after each deploy, and let uptime monitoring tell you when the site itself stops answering.
Andreas
Check your headers now
The Response Headers Inspector is free and shows cache and security headers for any URL, so you can confirm X-Frame-Options and your CSP in one pass. The rest of the toolkit, from the SSL Checker to traceroute and file sharing, is on pingfloat.com.

For broader hardening after this header, the web security checklist is a good next stop.
FAQ
Which header prevents clickjacking?
X-Frame-Options and CSP frame-ancestors both do. Modern browsers use frame-ancestors when it is present and fall back to X-Frame-Options otherwise, so send both. SameSite cookies add another layer.
Should I use DENY or SAMEORIGIN?
Use DENY if no page is ever framed, including by your own site. Use SAMEORIGIN when your own pages frame each other. For named outside partners, use frame-ancestors with their origins instead.
Can I allow one other site to frame my page?
Not with X-Frame-Options, since ALLOW-FROM is obsolete and ignored. Send Content-Security-Policy: frame-ancestors 'self' https://partner.example and leave X-Frame-Options off that route.
Why doesn't my meta tag work?
Framing policies are read only from HTTP response headers. Set the header in your web server, framework or CDN, then confirm it with a header inspector.
Sources
- X-Frame-Options header, MDN
- RFC 7034
- Clickjacking, MDN
- Clickjacking Defense Cheat Sheet, OWASP
- HTTP Headers Cheat Sheet, OWASP
- Response Headers, OWASP Secure Headers Project
- Modern web security guidance, Chrome
- Clickjacking mitigation, Lighthouse
- Prevent Clickjacking Exploits, Adobe Commerce
- How to Set X-Frame-Options, Arul John
- Cross-Origin-Resource-Policy, MDN
- Cross-Origin-Embedder-Policy, MDN
- Security headers, web.dev
- Web Security guidelines, Mozilla
- Host Header Injection, OWASP WSTG
