How to Embed a YouTube Video on Your Website (Responsive Code)
Updated November 2026
Written by the Toolpuffin team. Tools in this guide are tested in the browser.
To show a YouTube video on your own web page you paste a small piece of HTML, called an iframe, into the page. YouTube gives you a basic version, but it has a fixed size and few options. This guide explains the parts of the code, how to make it shrink on a phone and which options do what.
Get the code in one step
- Open the Embed Code Generator.
- Paste the link of the video, or just its 11-character ID.
- Choose the shape, the size and the player options.
- Copy the code and paste it into the HTML of your page.
YouTube also gives you code under the Share button of a video, then Embed. The generator adds the options that button does not show.
What the code contains
An embed is an iframe: a window in your page that shows another page, here the YouTube player. The address in it, the src, is the video with a few settings after a question mark.
| Part | What it does |
|---|---|
| src | The video address, with the options |
| width and height | The size of the player in pixels |
| title | A short description for screen readers |
| allow | Which browser features the player may use |
| allowfullscreen | Lets viewers go full screen |
Give the video a real title. People who use a screen reader hear it, and it is the only way for them to know what the frame holds.
Make it fit every screen
A fixed width of 560 pixels is too wide for a small phone. The usual fix is a wrapper around the iframe that keeps the 16:9 shape and lets the player fill it. The wrapper has a bottom padding of 56.25 percent, which is 9 divided by 16, and the iframe sits inside it at full width and height.
Choose Responsive in the generator and it writes this wrapper for you. Other shapes work the same way: 4:3, a square, or 9:16 for a Short.
Start at a time, loop, mute and more
| Option | What it does | Note |
|---|---|---|
| start | Starts the video at a number of seconds | Use 1:23 in the tool, it works out the seconds |
| autoplay | Starts when the page loads | Browsers usually allow it only when the video is muted |
| mute | Starts without sound | |
| loop | Plays the video again and again | Needs the video ID as a playlist, the tool adds it |
| controls=0 | Hides the player controls | Viewers cannot pause with the bar |
| rel=0 | Limits the related videos at the end to the same channel | It does not remove them |
If you want to link to a moment instead of embedding, the timestamp link generator makes a link that starts at a chosen time.
Privacy-enhanced mode
The generator can use youtube-nocookie.com instead of youtube.com. This is YouTube's privacy-enhanced mode. YouTube says that in this mode it does not store information about visitors to your page unless they play the video. The rules can change, so check YouTube's help pages if it matters for your site, for example under privacy rules in your country.
If the video does not show
- The owner of the video may have switched embedding off. Open the video on YouTube and look for a message.
- A private video cannot be embedded. Unlisted and public videos can.
- Check that the page address starts with https, and that nothing in your site stops frames from other sites.
- Open the page once after you paste the code. The generator does not contact YouTube, so it cannot test the video for you.
The code is made in your browser. Nothing you paste is sent anywhere.