Video

How to Embed YouTube Videos on a Website or Blog: Options and Fixes

Embedding lets readers watch a YouTube video without leaving your page, and the code is just a few clicks away. We cover getting the code, adding it to WordPress, the most useful options, responsive sizing, privacy-enhanced mode, fixing Error 153, and links that start partway through.

Published: 2026-10-16

If you want to feature a YouTube video on your blog or website, embedding it is usually better than just linking to it. Readers can watch without leaving your page and move back and forth between your text and the video. The embed code is only a few clicks away in YouTube's Share menu, but starting at a specific moment, keeping the player from overflowing on phones, or fixing a player that shows an error takes a little more know-how. This guide walks through getting the official code, the most useful options, responsive sizing, and troubleshooting, step by step.

Get the official embed code

You get the embed code from the video's page on YouTube. In a desktop browser, the steps are as follows (menu names and layout may change over time):

  1. Open the video you want to embed on YouTube.
  2. Click Share below the video.
  3. Choose Embed from the sharing options.
  4. Copy the code that appears (HTML starting with <iframe>).

The code looks roughly like this, with VIDEO_ID standing in for the video's unique ID:

<iframe width="560" height="315"
src="https://www.youtube.com/embed/VIDEO_ID"
title="YouTube video player" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerpolicy="strict-origin-when-cross-origin"
allowfullscreen></iframe>

Each attribute has a job: src is the video's embed URL, width and height set the display size, allow lists the features the player may use (such as autoplay), and allowfullscreen enables full-screen viewing. Pay special attention to referrerpolicy="strict-origin-when-cross-origin": it helps prevent Error 153 (covered below), so don't remove it when tidying up the code. The video ID is the part after "v=" in a regular watch URL (https://www.youtube.com/watch?v=VIDEO_ID).

Add it to WordPress or a blog

In the WordPress block editor, you have two options:

MethodHowBest for
YouTube embed blockAdd the block and paste the video URLSimply showing a video
Custom HTML blockPaste the iframe embed code as isFine-tuning start time, looping, and other options

The YouTube embed block is the quickest, but a URL-only embed may not carry over detailed options. If you need a start or end time, looping, or privacy-enhanced mode, paste your customized code into a Custom HTML block instead. Most other blogging platforms offer either automatic embedding when you paste a URL or an HTML editing mode. Some services restrict iframes, though, so check your platform's help pages.

Useful player parameters

You can control how the player behaves by adding parameters to the end of the URL in the embed code's src, starting with "?". To add more than one, join them with "&" (if the URL already contains a "?", join new parameters with "&" as well). For example, to play from 1:23 to 2:00 and limit related videos to the same channel:

https://www.youtube.com/embed/VIDEO_ID?start=83&end=120&rel=0
ParameterWhat it doesExample
startStart playback at a time (in seconds)start=83 (from 1:23)
endStop playback at a time (in seconds)end=120 (stops at 2:00)
autoplayPlay automatically when loadedautoplay=1&mute=1
muteStart with the sound mutedmute=1
loopStart over after reaching the endloop=1&playlist=VIDEO_ID
controlsHide the player controlscontrols=0
relLimit related videos to the same channelrel=0
cc_load_policyShow captions by default (if available)cc_load_policy=1
playsinlinePlay inline on iPhone instead of full screenplaysinline=1

Note that start and end take seconds only: 1:23 is 60 + 23 = 83, and 1:02:05 is 3600 + 120 + 5 = 3725. As for rel=0, since a 2018 change it no longer removes related videos entirely; instead, it shows videos from the same channel. That's useful if you don't want other channels' videos appearing, but it doesn't hide suggestions altogether (all based on YouTube's documentation; behavior may change).

Writing these by hand is tedious and easy to get wrong. With the YouTube Embed Code Generator, you enter a video URL and pick your options (start and end times, autoplay with mute added automatically, looping, privacy-enhanced mode, and responsive sizing in 16:9, 4:3, or 9:16), and it builds the code for you. A live preview lets you confirm the behavior before you copy it.

Autoplay and looping: what to know

  • Pair autoplay with mute. Most browsers block autoplay with sound, so autoplay=1 alone may not start the video. Combine it with mute=1, and make sure the iframe's allow attribute includes "autoplay" (the official code does).
  • Looping needs a playlist parameter. To loop a single video, add playlist= with the same video ID alongside loop=1.
  • Put readers first. A video that springs to life the moment a page opens can startle readers and eat into their data. Save autoplay for cases that call for it, such as short silent demos.

Details such as how start and end times interact with looping can vary by environment, so test on both a computer and a phone before publishing. And if you just want to replay a section yourself, you don't need an embed at all: the YouTube Repeat Player loops any part of a video for you.

Make embeds fit phone screens (responsive sizing)

The official code fixes the size with width="560" height="315", so on narrow screens like phones the player can overflow. To make it scale with the screen, add a style attribute to the iframe:

<iframe ... style="width:100%; aspect-ratio:16/9; height:auto"></iframe>

width:100% stretches the player across its container, and aspect-ratio keeps the height in proportion to the width. You can leave the width and height attributes in place. Match the ratio to the video:

Video typeaspect-ratio value
Standard landscape video16/9
Older TV-style video4/3
Shorts (vertical)9/16

A vertical Short at 100% width can end up taller than the screen, so add a max-width such as max-width:360px to keep it at a comfortable size. Older tutorials often wrap the iframe in a div and use padding-top to reserve space for the ratio. That approach still works, but in today's major browsers aspect-ratio does the same job far more simply.

Use privacy-enhanced mode

YouTube also offers a privacy-enhanced mode for embeds, designed with viewers' privacy in mind. To use it, change the domain in the embed code's src from "www.youtube.com" to "www.youtube-nocookie.com":

src="https://www.youtube-nocookie.com/embed/VIDEO_ID"

It's worth considering if you want to be as considerate of readers' privacy as possible. Parameters like start and rel can generally be added the same way as with a regular embed. Keep in mind that the video itself is still delivered by YouTube, so you're still using an external service. Check YouTube's documentation for details on what information is handled, and mention embedded content in your site's privacy policy.

Troubleshooting: when the embed won't show or play

If an embedded video won't appear or shows an error instead of playing, check the following.

SymptomPossible causeWhat to check or do
"Error 153: Video player configuration error"The page is set not to send a RefererKeep the referrerpolicy attribute and check your site-wide settings (see below)
The player appears but won't playThe owner may not allow embeddingLink to the video on YouTube instead
A message says the video can't be playedThe video is private or has been removedOpen the video's URL to check its status
Nothing appears at allPart of the code is missing, or the blog stripped the iframePaste the code again and confirm the editor accepts HTML

Fixing Error 153

Error 153 can occur when the page is set up not to send a Referer (information about which page a request came from). Check these places:

  • Make sure the iframe doesn't use referrerpolicy="no-referrer"; if it does, restore the official referrerpolicy="strict-origin-when-cross-origin".
  • Check whether your server configuration (such as .htaccess) or a security plugin sends Referrer-Policy: no-referrer for the whole site.
  • If your HTML includes a referrer meta tag, make sure it isn't set to no-referrer.

Sometimes the error shows up after someone "cleans up" the embed code by deleting attributes. Even if an attribute looks unnecessary, it's safest to leave the official code as is. Opening an HTML file directly from your computer to test it can also trigger the same error, so test embeds on a page served from a web server.

Sometimes you don't need an embed, just a link that starts the video at a specific moment. For that, add "t=" to the video's URL:

Link typeExample (starts at 1:23)
Short URL, in secondshttps://youtu.be/VIDEO_ID?t=83
Standard URL, in minutes and secondshttps://www.youtube.com/watch?v=VIDEO_ID&t=1m23s

The simplest way is YouTube's Share menu. Pause the video where you want it to start, open Share, and check Start at; the link will begin from that time. Don't mix up the two formats: the embed parameter start takes seconds only, while the t in a share link accepts seconds or a minutes-and-seconds format like "1m23s". The YouTube Embed Code Generator can create these timed links, too. And if you want viewers to find specific scenes on YouTube itself, adding chapters helps; see how to add chapters to YouTube videos.

Think of embedding as three steps: get the official code, add the parameters you need, and make the width flexible for phones. Two more things to remember: don't delete the referrerpolicy attribute, which helps avoid Error 153, and pair autoplay with mute. This article reflects general information at the time of writing. Embed parameters and behavior can change, so check YouTube's official documentation and Help for the latest details.

FAQ

Where do I get the embed code for a YouTube video?

Click Share below the video and choose Embed. Copy the code that starts with <iframe> and paste it into your site's HTML or a WordPress Custom HTML block.

How do I make an embedded video start at a specific time?

Add the start time in seconds to the src URL, such as ?start=83 for 1:23. Use end to stop at a set time, and join parameters with &, as in ?start=83&end=120.

Why won't my embedded video autoplay?

Most browsers block autoplay with sound. Add mute=1 alongside autoplay=1 so the video starts muted, and make sure the iframe's allow attribute includes autoplay.

Can rel=0 hide related videos completely?

No. Since a 2018 change, rel=0 no longer removes related videos; instead, it limits them to videos from the same channel. It helps keep other channels' videos from appearing, but some suggestions will still show.

What causes "Error 153" and how do I fix it?

It can happen when the page is set not to send a Referer, the information about which page a request came from. Keep referrerpolicy="strict-origin-when-cross-origin" from the official code, and check that your site settings or a plugin aren't sending Referrer-Policy: no-referrer.