Can you embed youtube.com in an iframe?

No — youtube.com blocks iframe embedding. youtube.com responds with `X-Frame-Options: SAMEORIGIN`. The page can only be framed by pages on the same origin (youtube.com itself). From any other domain — including yours — the browser blocks it.

Live Test In Your Browser

We just tried loading youtube.com in a real iframe below. If the site appears, embedding works from your browser. If it stays blank or shows an error, it is blocked.

Open in the full tester →

What youtube.com Sends

X-Frame-Options: sameorigin

X-Frame-Options: SAMEORIGIN. SAMEORIGIN is common for logged-in dashboards and account pages: youtube.com frames its own pages internally but refuses every external embedder. You will see the page load fine when you open it directly, but a "refused to connect" error inside an iframe on your site. Use an official embed method if youtube.com offers one.

Source: curated reference · last checked 2026-06-12

The Right Way To Embed YouTube

Use the privacy-friendly youtube.com/embed/ player URL instead of the watch page.

<iframe width="560" height="315"
  src="https://www.youtube.com/embed/VIDEO_ID"
  title="YouTube video player"
  frameborder="0"
  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
  allowfullscreen></iframe>

The main watch page (youtube.com/watch) sends X-Frame-Options: SAMEORIGIN and cannot be framed. The dedicated /embed/ endpoint is built for embedding. Use youtube-nocookie.com for reduced tracking.

Full guide: how to embed YouTube →