Free auditStart free
GlossaryGlossary · Security headers

X-Frame-Options

X-Frame-Options is an HTTP response header that controls whether a page can be framed. Learn DENY vs SAMEORIGIN, why ALLOW-FROM is obsolete and what replaces it.

3 min
read
3
sources
Oct 25, 2026
updated
Scaplet Editorial Team
author
In one line

X-Frame-Options is an HTTP response header that tells a browser whether it may render your page in a frame, iframe, embed or object. MDN says sites use it to avoid clickjacking and some cross-site leaks. The two working values are DENY and SAMEORIGIN. The ALLOW-FROM value is obsolete, and Content-Security-Policy frame-ancestors is the modern replacement.

30-second check

Is this costing your site traffic?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01Explained

What X-Frame-Options does

MDN describes X-Frame-Options as an HTTP response header that "can be used to indicate whether a browser should be allowed to render the document in a <frame>, <iframe>, <embed> or <object>." The point is to stop other sites from embedding your pages, which MDN says helps avoid clickjacking attacks and some cross-site leaks.

RFC 7034 states the same purpose: it describes a policy sent from the server to the browser about whether the content may be displayed in frames that are part of other web pages. The RFC is Informational, not an Internet Standards Track document. It was written down after browser vendors had already shipped the header.

The header is enforced by the browser that renders your page inside someone else's page. Set it as part of your wider security headers.

03Check it

X-Frame-Options vs CSP frame-ancestors

MDN's note on ALLOW-FROM points to the replacement: the Content-Security-Policy header has a frame-ancestors directive "which you should use instead." RFC 7034 says ALLOW-FROM supports only one serialized origin, while frame-ancestors takes a space-separated list of sources.

Decision rule: if nobody should embed your pages, send DENY or frame-ancestors 'none'. If only your own site frames them, use SAMEORIGIN or frame-ancestors 'self'. If a named partner must embed them, use frame-ancestors only.

Similar policies with frame-ancestors
Content-Security-Policy: frame-ancestors 'none'

Content-Security-Policy: frame-ancestors 'self'
04Worth knowing

Gotchas

A meta tag does nothing

MDN warns that setting X-Frame-Options in a <meta> element has no effect. It is only enforced through HTTP headers, so set it on the server, CDN or framework. MDN also says the CSP frame-ancestors directive is not supported in a <meta> element.

It is per response

Send it on every HTML response you want protected, not just the homepage.

Legitimate embeds break

A widget, preview tool or checkout that you iframe from your own domain needs SAMEORIGIN, not DENY.

ALLOW-FROM silently fails

Browsers ignore the entire header when they see it, so a page that relied on it may be unprotected.

05How it works

Check it in 2 minutes

  1. 01

    Open DevTools

    Load the page, open the Network tab and select the document request.

  2. 02

    Read the response headers

    Look for X-Frame-Options and for a Content-Security-Policy header with frame-ancestors.

  3. 03

    Test an embed

    Put the URL in an iframe on a page from another origin and confirm the browser refuses to render it when you expect it to.

Questions

Asked a lot.

4 questions people ask next, answered from the sources on this page.

01What does X-Frame-Options do?

It tells the browser whether it may display your page inside a frame, iframe, embed or object on another page. Sites use it to avoid clickjacking.

02Should I use DENY or SAMEORIGIN?

Use DENY if no one should embed the page. Use SAMEORIGIN if only pages from your own origin should frame it.

03Is X-Frame-Options deprecated?

The ALLOW-FROM directive is obsolete and ignored by modern browsers. MDN tells sites to use CSP frame-ancestors instead of it.

04Can I set X-Frame-Options in a meta tag?

No. MDN says a meta element has no effect. It only works as an HTTP response header.

Sources · 3

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • mozilla.org
  • rfc-editor.org
  1. 01MDN: X-Frame-Options headerdeveloper.mozilla.org · checked 2026-10-25
  2. 02MDN: Content-Security-Policy frame-ancestors directivedeveloper.mozilla.org · checked 2026-10-25
  3. 03RFC 7034: HTTP Header Field X-Frame-Optionsrfc-editor.org · checked 2026-10-25
Free · 2 minutes

Know the term. Now check your site.

The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • +212% organic clicks in 90 days Ledgerly