What Is an Embed Code?
A snippet of HTML, usually an iframe, that displays a YouTube video directly on a web page.
An embed code is a short piece of HTML that a website owner pastes into a page so a YouTube video plays there instead of only being reachable via a link. YouTube generates it as an <iframe> element pointing at a special /embed/ URL for the video.
What’s inside an embed code
At minimum it contains a source URL with the video ID, a width and height (or a responsive wrapper instead), and a title attribute for accessibility. Optional parameters control autoplay, start time, controls visibility and more.
How to get one
You can copy YouTube’s own version from the Share panel under a video, or use the embed code generator on this site to add responsive sizing, privacy mode, start times and other options that YouTube’s default panel does not offer together.
A closer look at how an embed code is built
An embed code is not one fixed string; it is assembled from a few interchangeable parts. The domain (youtube.com or the privacy-enhanced youtube-nocookie.com) determines cookie behaviour. The path carries either a single video ID or, for a playlist, the videoseries path with a list parameter. Query parameters like start, autoplay and controls sit after a question mark and modify playback. And the surrounding markup, either fixed width/height attributes or a responsive wrapper div, determines how the player is sized on the page. Understanding these separable parts makes it much easier to read, and to hand-edit, an embed code you did not generate yourself.
A practical example
Suppose you want to show a product demo video on a landing page, privacy-friendly, starting 15 seconds in to skip an intro, with no autoplay. The resulting embed code combines a youtube-nocookie.com domain, a start=15 parameter, and a responsive wrapper:
<div style="position:relative;width:100%;padding-bottom:56.25%;height:0;overflow:hidden;">
<iframe src="https://www.youtube-nocookie.com/embed/VIDEO_ID?start=15" style="position:absolute;top:0;left:0;width:100%;height:100%;border:0;" title="Product demo" allowfullscreen loading="lazy"></iframe>
</div>
Every piece of that snippet maps directly to a choice: the domain for privacy, start=15 for the skip, and the wrapper for responsive sizing.
Embed code vs. a plain link
It is worth being clear about what an embed code is not. A plain YouTube link (a watch or youtu.be URL) is meant for sharing and clicking; pasted as plain text on a page, it just sits there as a URL, or gets automatically converted to an embed by platforms like WordPress that support oEmbed. An embed code, by contrast, is explicit HTML you control directly, giving you the sizing, privacy and playback options a plain link does not expose. Related concepts worth understanding alongside this one are the iframe element the code relies on and the distinction between the embed URL and watch URL.
Frequently asked questions
What is an embed code used for?
It lets a website show a YouTube video directly on the page, using an iframe, instead of only linking out to YouTube.
Where do I get an embed code?
YouTube’s own Share panel provides one, or use our embed code generator for a responsive, privacy-friendly version with more options.
Build your embed code
Our generator writes a privacy friendly embed code you can paste straight into your page.