How to Embed a YouTube Video on Your Website
Learn how to embed a YouTube video, make the player responsive, check privacy and accessibility, and avoid common implementation problems.

Tool Free
Thumbnail Downloader
Download YouTube thumbnails in HD quality.
Embedding a YouTube video lets visitors watch it from a page on your website without uploading a separate video file. The basic process is simple: get the embed code from YouTube, place it where the player should appear, and check the result on desktop and mobile. The details matter, though. Responsive sizing, accessibility, privacy expectations, and permissions all contribute to a good experience.
Copy the official YouTube embed code
- Open the YouTube video you want to feature.
- Select Share, then choose Embed.
- Review the available options, such as starting at a particular time, if they fit your purpose.
- Copy the iframe code shown by YouTube.
- In your website editor or content management system, add an HTML/embed block and paste the code.
- Save or preview the page, then test the player in the contexts your audience uses.
The code generally uses an iframe pointing to a YouTube embed URL. Prefer the official code for the chosen video rather than constructing a URL from memory. Your site builder may offer a dedicated YouTube block; use it if it gives you the needed display and control.
If you want a starting point without manually adjusting markup, the Embed Code Generator can help create an embed. Verify the generated settings and test the result on your own site before publishing.
Make the video responsive
A fixed-width iframe can overflow a narrow phone screen. A responsive wrapper allows the player to scale with the available width while preserving the familiar 16:9 shape. If you use a page builder, look for its responsive video or aspect-ratio setting. For a custom page, a CSS wrapper is a straightforward approach:
<div class="video-frame">
<iframe
src="https://www.youtube.com/embed/VIDEO_ID"
title="Video: descriptive title"
loading="lazy"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerpolicy="strict-origin-when-cross-origin"
allowfullscreen>
</iframe>
</div>.video-frame {
aspect-ratio: 16 / 9;
width: 100%;
}
.video-frame iframe {
border: 0;
height: 100%;
width: 100%;
}Replace VIDEO_ID with the ID from the video’s official embed URL. Keep the iframe title meaningful: it should identify the video rather than merely say “iframe.” A browser or older layout may need a fallback strategy if it does not support the CSS aspect-ratio property; test with the site’s supported browser range.
Use a privacy-enhanced embed when appropriate
YouTube offers a privacy-enhanced embed option. In the official embed flow, choose the relevant privacy-enhanced setting if available, or consult current YouTube documentation for the appropriate domain and behavior. This can change how viewing data is handled before playback, but embedding third-party content may still involve data processing when a visitor interacts with or loads the player. It is not a substitute for an accurate privacy notice or consent practices required in your jurisdiction.
Do not enable autoplay by default simply to attract attention. Unexpected sound or motion can disrupt visitors, create accessibility concerns, and make a page feel intrusive. Let viewers choose when to start playback unless there is a clear, accessible reason for a different behavior.
Accessibility and context
An embedded player should make sense within the page, not appear as an unexplained rectangle. Introduce it with a clear heading or sentence that tells visitors what they will learn. Give the iframe a descriptive title, and confirm that the video has accurate captions. Captions help people who are deaf or hard of hearing, viewers in noisy environments, and people watching without audio.
Do not rely on the player alone to convey essential information. Add a concise text summary or transcript when appropriate, especially if the page’s purpose depends on details in the video. Keep keyboard navigation in mind and test that visitors can reach and operate the player controls. Follow your site’s established color contrast and accessibility practices around the embed.
Good practice: Make the video optional, clearly labeled, and usable without requiring visitors to guess what it contains.
Common embed problems and fixes
“Video unavailable” or playback error
The creator may have disabled embedding, the video may be private or removed, or restrictions may apply to the current viewer or location. Confirm the source video’s sharing status and test while signed out. Choose a video that is permitted to appear on your site; do not attempt to bypass access controls.
Player is too large or clipped
Check the parent container’s width, overflow rules, and fixed dimensions. Use a responsive video block or wrapper, then test at a narrow viewport. A theme style can override iframe dimensions, so inspect the page’s own layout rules if the issue persists.
Player loads slowly
Third-party players can add network requests and affect page performance. Consider lazy loading below-the-fold embeds, limiting the number of players on one page, or using a lightweight preview that loads the actual player only after a visitor chooses to play. Make sure any preview provides a clear action and remains accessible. Measure your page rather than assuming a particular technique will improve every site.
Embed works in preview but not on the published site
Your content management system, security policy, or hosting configuration may restrict iframe content. Use the platform’s approved embed block and consult its documentation or administrator. Avoid removing security protections broadly just to force an embed to work.
Choose the right placement
Place the video near the text that explains why it is relevant. A tutorial may benefit from an embed beside the instructions; a product page may need a short demonstration near the feature it shows. Avoid placing multiple unrelated players above the main content, especially on mobile where embeds can push useful information far down the page.
Use a descriptive heading and a short caption where needed. If you want visitors to continue to related content, point to a genuinely useful next step rather than adding a cluster of unrelated links. The Description Generator can help draft concise supporting copy, while the Video SEO Analyzer can support video metadata review. Visit all creator tools for other utilities.
Permissions, copyright, and maintenance
Embedding a video is not the same as owning it or receiving permission to reuse its content elsewhere. Use YouTube’s provided embed functionality and respect the creator’s settings, applicable platform terms, and relevant rights. Do not download and re-upload another person’s work unless you have the necessary rights and permissions.
Review important embeds periodically. The source may become unavailable, the page design may change, or captions and surrounding instructions may need an update. If a video is central to a service or public information page, consider maintaining an accessible alternative such as written instructions or a transcript.
Pre-publish checklist
- The video is relevant, available, and allowed to be embedded.
- The player fits phone and desktop layouts without horizontal scrolling.
- The iframe has a descriptive title and controls can be reached by keyboard.
- Captions are present and reviewed; essential content has a text alternative where useful.
- Autoplay is off unless there is a well-justified accessible design need.
- Privacy disclosures and consent behavior match the site’s obligations.
- The page remains usable if the external video is unavailable.
Key takeaways
- Copy the embed code from YouTube’s Share menu or use your site builder’s supported video block.
- Use a responsive layout so the player fits small screens.
- Provide a descriptive iframe title, captions, and helpful surrounding context.
- Consider privacy, performance, autoplay, and applicable consent requirements.
- Respect creator settings and rights, then test and maintain the published embed.
Frequently asked questions
How do I embed a YouTube video on my website?
Open the video, select Share, choose Embed, copy the iframe code, and paste it into your site’s HTML/embed block or supported video component. Preview the published page.
How do I make an embedded YouTube video responsive?
Use your site builder’s responsive video setting or place the iframe in a full-width wrapper with a 16:9 aspect ratio and an iframe sized to fill it. Test on narrow screens.
Can I embed a video if the creator disabled embedding?
No. Respect the creator’s settings and choose a video that is available for embedding. Do not try to bypass restrictions.
Does embedding a video affect website privacy?
A third-party player can involve data processing, particularly when loaded or used. A privacy-enhanced option may change behavior, but it does not replace appropriate disclosures and consent practices.
Should I autoplay an embedded YouTube video?
Usually not. Autoplay can surprise visitors, disrupt access, and consume data. Let people choose playback unless a well-justified design requires otherwise.