Having relevant video content on your website can be an engaging feature. Maybe you are giving instructions on a subject, but you feel like it would be comprehended better when it’s also shown by video, or you have a corporate website in which you want to show a video from your business on YouTube. Possibilities are endless on why you want to play a video on your blog or website, but converting videos to different formats to play on your website can be time-consuming and complicated. The easiest way to add a video in HTML is to let YouTube play the videos on your web page by embedding the video. Here is a step by step guide on how to embed a YouTube video in HTML.
How to Insert a Video in HTML Using the Embed Code?
Follow these steps to embed videos in your webpage:
- Open the YouTube page and find the video you want to embed.
- Click on the “Share” button located under the video to open the sharing options.
- Next, click on the “Embed” option, which will appear under “Share a Link.” This will open a screen with the YouTube video embed code, which is also called an iframe code.
- Here you can adjust the dimensions of the video by setting the width and height.
- YouTube also allows you to customize your video by giving you the option to start it from the point you want. Type in the desired starting time next to space at the “Start at” option and check the box.
- While you are here, you can add any other parameters you want to the URL. (Details are under “How to Use Parameters”)
- Click “Copy” to copy the YouTube embed code to your clipboard.
- Open your web page’s HTML options. Websites are built with HTML codes, and the YouTube embed code is designed to fit into this code so that the video is shown without any changes.
- Find where you want to put your video in the HTML page. Everything you have displayed on the page is also written in the code. So, for example, if you want your video to be under the title “How to Embed Tutorial,” your code will look something like this:
<title>How to Embed Tutorial</title>
<iframe width=”560″ height=”315″ src=”https://www.youtube.com/embed/6zbsUtQL4nY” frameborder=”0″allow=”accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture” allowfullscreen></iframe>
- Paste the video code where you want it to be.
- Save the changes. Check if the video is at the right spot on the website.
How to Use Parameters?
YouTube offers some options to customize the video playing experience. You can still add some more features if you tinker a little bit with the embed code by adding additional parameters. Here we gathered some useful parameters you might want to make use of.
1. YouTube Controls Parameter
By using the YouTube controls parameter, you can either hide the controls at the bottom of the video or let it stay.
‘controls=0’ means player controls do not display
‘controls=1’ means player controls display
2. Modestbranding Parameter
The modestbranding parameter is responsible for showing any type of branding. In this case, you can hide the logo and branded play button present in Youtube videos. Add ‘modestbranding=1’ to the iframe code to remove branding.
3. Loop Parameter
If you want to play your video on loop forever, you have to use the loop parameter. ‘loop=1’ means the video will loop, whereas ‘loop=0’ means the video will only play once, which is also the default mode.
4. YouTube Video Autoplay Parameter
You can make an embedded video start to play automatically on your webpage by using the autoplay parameter. Adding ‘autoplay=1’ to the embed code will make the video play automatically.
5. Mute Parameter
If you are using the autoplay or loop parameter, you might want to consider adding the mute parameter as well because an automatically starting or never-ending video can annoy your visitor and cause them to leave your website prematurely. ‘mute=1’ means that the video will play on mute.
NOTE: To use any of the parameters, add the ones you want to the videos embed code, right after the video ID using ‘&’. (e.g. <iframe width=”560″ height=”315″ src=”https://www.youtube.com/embed/5cWa4tbSmp?&modestbranding=1&loop=1”
FAQs on How to Embed a YouTube Video in HTML
You can make an embedded video play automatically by adding &‘autoplay=1′ to the videos embed code after the video id.
If you want to start your video at a certain time, just add the time you want it to start next to the “Start at” box which will appear when you open the embed code on YouTube or add ‘?start=(time)’ to the video’s embed code.
To make an embedded video play on a loop and on mute, add ‘&loop=1&mute=1″ to the YouTube embed code.
If you don’t want your video to be potentially embedded in external sites, you can turn off embedding. Sign in to YouTube Studio, select “Videos” on the left-hand menu, then select details on the video you want to manage. Go to “more options” and untick the box next to “Allow Embedding”. Save the changes you made.
The privacy-enhanced mode allows you to embed videos without using any cookies to monitor viewing behavior. If you don’t want YouTube to collect any information from your website visitors, activate the privacy-enhanced mode by checking the box under the YouTube video embed link.
Conclusion on How to Embed a YouTube Video in HTML
In this article, we have gone over why using a YouTube video on your website or blog post can be beneficial and explained how to embed a YouTube video with the embed code provided by YouTube to HTML. Additionally, we detailed the use of parameters, their functions, and how the addition of parameters can customize the video’s playing experience on your website according to your needs.
If you liked this video about inserting a YouTube video in HTML, you can also be interested in our other articles about YouTube such as how to make a GIF from a YouTube video.