How to Embed a Video on YouTube | Copy the Iframe Code

Embedding a video from YouTube requires copying its HTML iframe code from the Share menu and pasting it directly into your website’s source.

One wrong click can leave you with a plain link instead of a working player. The official workflow runs through the Share button on a computer, where a single Embed option reveals the exact code your site needs. A five-second copy-paste is all it takes once you know where to look, and the same menu gives you control over autoplay, start timing, and privacy-enhanced mode.

How to Generate the Embed Code

The embed code lives inside YouTube’s Share menu on every video and playlist page, but it only appears when you open the site on a computer.

  1. Open the YouTube video or playlist on a computer.
  2. Click the Share button located below the video player.
  3. In the pop-up panel, select Embed.
  4. A box displays the HTML iframe code containing the video’s embed URL and default player dimensions.
  5. Click Copy to capture the full code to your clipboard.
  6. Go to your website’s page editor, switch to the HTML view or source code mode, and paste the iframe code where you want the player to appear.

Embed Format and Player Basics

YouTube’s embedded player is served through a straightforward URL pattern: https://www.youtube.com/embed/VIDEO_ID. The platform supports embedding via either an <iframe> tag (the standard method) or the IFrame Player API for more advanced customization. The minimum allowed player size is 200 pixels by 200 pixels.

A typical embed code looks like this, with the video ID replacing the placeholder:

<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>

Adding Autoplay, Start Time, and Captions

Three of the most requested player behaviors are controlled by adding small parameter strings to the embed URL. You append these directly to the src value inside your iframe tag.

  • Autoplay: Add &autoplay=1 immediately after the video ID. Note that browser policies often override this setting, so autoplay may not work in every context despite the parameter being present.
  • Start time: Add ?start=NUMBER where NUMBER is the second from which playback should begin. Use an ampersand instead of a question mark if the URL already has a parameter.
  • Captions: Add &cc_load_policy=1 to force captions on by default when the video has them available.

Multiple parameters are combined with ampersands: &autoplay=1&cc_load_policy=1.

Parameter Code to Add What It Does
Autoplay &autoplay=1 Starts video playback automatically when the page loads
Start time ?start=30 or &start=30 Begins playback at the specified second
Captions on by default &cc_load_policy=1 Displays captions immediately if the video supports them
Privacy-enhanced mode Domain change only Uses youtube-nocookie.com instead of youtube.com
Playlist embed Same Share → Embed path on a playlist page Generates a player that cycles through playlist videos
User uploads embed listType=user_uploads&list=USERNAME Loads a specific user’s uploaded videos into the player

Privacy-Enhanced Embeds Without Cookies

YouTube provides a dedicated embed domain that does not set cookies on the viewer’s browser until they press play. The change requires no new code generation — just a domain swap in the existing embed URL. Switch https://www.youtube.com to https://www.youtube-nocookie.com inside your iframe’s src attribute. Site networks must allowlist youtube-nocookie.com alongside the standard youtube.com domain for this mode to work.

Why Your Embed Might Not Appear

Four common mistakes cause the player to fail silently on the page.

  • Using the share link instead of the embed code. The Share menu offers both a plain link and an Embed option. Copying the URL from the address bar or the share link pop-up produces only a clickable text link, not a working player.
  • Pasting into a plain-text field. Many website builders have separate fields for a video URL and for raw HTML. The embed code must go into the HTML or source code area — pasting it into a URL-only field will not render the player.
  • The video owner blocked embedding. Creators can disable embedding on individual uploads. If the embed code results in a blank area or an error, the video’s settings in YouTube Studio may have embedding turned off.
  • Network restrictions. Managed networks, school filters, and corporate firewalls sometimes block the youtube.com or youtube-nocookie.com domains. Check your site’s network policy when embeds work on one connection but not another.

How to Stop Others From Embedding Your Video

If you upload your own content and want to prevent external sites from using it inside a player, the toggle lives in YouTube Studio. Sign in, go to Content, open Details for the specific video, click SHOW MORE, uncheck Allow embedding, and save. Once this setting is active, any embed code for that video will fail to play on third-party domains.

Your Quick Embed Checklist

Before you publish a page with an embedded YouTube video, confirm each of these points:

  1. The embed code came from Share → Embed on a computer, not a mobile browser.
  2. The code includes the correct <iframe> tags and a valid src URL.
  3. Any parameters (autoplay, start time, captions) are added with proper ampersand or question-mark syntax.
  4. The paste target in your website editor supports raw HTML — not just a plain URL input.
  5. For privacy-enhanced embeds, the domain is youtube-nocookie.com and your network allows it.
  6. The video’s owner has not disabled embedding in YouTube Studio.
  7. The player size is at least 200 by 200 pixels.

References & Sources