X-Frame-Options tells browsers whether other sites may show your page inside a frame. Without it, anyone can load your page in an invisible frame over their own and trick visitors into clicking your buttons — clickjacking. The modern way is the CSP frame-ancestors directive; send both for older browsers.
| Defined in | The HTML Standard (it superseded RFC 7034) |
| Values | DENY or SAMEORIGIN |
| Modern form | Content-Security-Policy: frame-ancestors |
| When both are sent | frame-ancestors wins; X-Frame-Options is ignored |
| Browser support | Every current browser |
Check clickjacking protection on your site
Enter a domain: we fetch its homepage and read every security header, this one first.
What it does
In a clickjacking attack, another site loads your page in a transparent frame and places its own content over it, so a visitor who thinks they are clicking a harmless button is really clicking yours — a transfer, a setting, a like. A page that refuses to be framed cannot be used that way.
The CSP frame-ancestors directive does the same job with more precision — it can list the origins allowed to frame you — and when a response carries both, browsers follow frame-ancestors and ignore X-Frame-Options. Neither works from a <meta> tag: they must be response headers.
Directives and values
| Directive or value | What it does |
|---|---|
DENY | No site may frame the page, not even your own. |
SAMEORIGIN | Only pages from your own origin may frame it — every frame up the chain must be same-origin. |
ALLOW-FROM uri | Obsolete. Current browsers ignore the whole header when they see it, so the page can be framed from anywhere. |
frame-ancestors 'none' | The CSP equivalent of DENY. |
frame-ancestors 'self' https://partner.example | Your own origin plus the ones listed — what ALLOW-FROM tried to do. |
What to send
X-Frame-Options: DENY
Content-Security-Policy: frame-ancestors 'none'
Use SAMEORIGIN and frame-ancestors ‘self’ if the site frames its own pages. If you already send a Content-Security-Policy, add frame-ancestors to it rather than sending a second policy.
How to set it
Apache
Header always set X-Frame-Options "DENY"
In the virtual host or .htaccess; needs mod_headers (and AllowOverride FileInfo for .htaccess). always also covers error pages and redirects, which plain Header set skips.
nginx
add_header X-Frame-Options "DENY" always;
In the server block. A location with any add_header of its own drops every add_header from the server block — repeat them there, or from nginx 1.29.3 use add_header_inherit merge;.
IIS (web.config)
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-Frame-Options" value="DENY" />
</customHeaders>
</httpProtocol>
</system.webServer>
Caddy
header X-Frame-Options "DENY"
Cloudflare
Rules → Overview → Create rule → Response Header Transform Rule
Set static — header name: X-Frame-Options — value: DENY
On every plan, for records that are proxied through Cloudflare. Set replaces the header if your server already sends one.
WordPress
add_action( 'send_headers', function () {
header( 'X-Frame-Options: DENY' );
} );
In a small plugin or the theme’s functions.php. PHP only runs for pages WordPress builds, so images, scripts and other static files do not get the header — set it at the server or CDN to cover everything.
Common mistakes
- Setting it in a <meta> tag, which has no effect.
- Using ALLOW-FROM: browsers ignore the header, leaving no protection at all.
- The web server and the application both sending it with different values — browsers treat conflicting values as “deny”, which may break framing you wanted.
- Sending a permissive frame-ancestors in an enforced CSP and expecting X-Frame-Options to still apply — it is ignored.
What we recommend
Send X-Frame-Options: DENY and frame-ancestors ‘none’, unless a specific page needs to be framed — then use SAMEORIGIN and ‘self’, or list the origins in frame-ancestors.
Questions
Should I use X-Frame-Options or frame-ancestors?
frame-ancestors, which is the current standard and can list origins; add X-Frame-Options too for older browsers. When both are present, browsers follow frame-ancestors.
Why does my scanner still say “no clickjacking protection”?
Usually because the header is set in a <meta> tag, uses ALLOW-FROM, or is sent only on some pages. It must be a response header on every page that could be framed.
Sources
Checked on 25 September 2026 against these official sources:
- HTML Standard: the X-Frame-Options header — html.spec.whatwg.org
- X-Frame-Options header — developer.mozilla.org
- Content-Security-Policy: frame-ancestors directive — developer.mozilla.org
- Clickjacking Defense — cheatsheetseries.owasp.org