Toolpuffin

    Loading...

    Up and down to choose, Enter to open, Esc to close.

    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

    1. Open the Embed Code Generator.
    2. Paste the link of the video, or just its 11-character ID.
    3. Choose the shape, the size and the player options.
    4. 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.

    PartWhat it does
    srcThe video address, with the options
    width and heightThe size of the player in pixels
    titleA short description for screen readers
    allowWhich browser features the player may use
    allowfullscreenLets 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

    OptionWhat it doesNote
    startStarts the video at a number of secondsUse 1:23 in the tool, it works out the seconds
    autoplayStarts when the page loadsBrowsers usually allow it only when the video is muted
    muteStarts without sound
    loopPlays the video again and againNeeds the video ID as a playlist, the tool adds it
    controls=0Hides the player controlsViewers cannot pause with the bar
    rel=0Limits the related videos at the end to the same channelIt 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.

    More guides