How to Embed Youtube Video In HTML
As in our previous article, we talk about what is HTML? & Basics of HTML. Now we are going to talk about how to embed YouTube videos in an HTML website, or I will provide you with the HTML code for video embedding in any HTML website.
For that, you required a few things.
- Uploaded video link on YouTube
- <iframe> of the element in your web page
- Width and height According to your requirement
So below are the example
Playing A YouTube video in HTML
<!DOCTYPE html>
<html>
<body>
<iframe width=”450″ height=”370″ src=”https://www.youtube.com/embed/VfnAOeVXgmk”>
</iframe>
</body>
</html>
So, this is just the normal format in this but if you want some changes then so few more things are mentioned below.
How to do Autoplay + muted YouTube Video
Just add mute=1 after autoplay=1 and your video will start automatically and the video will be muted.
<!DOCTYPE html>
<html>
<body>
<iframe width=”450″ height=”370″ src=”https://www.youtube.com/embed/VfnAOeVXgmk?autoplay=1&mute=1″>
</iframe>
</body>
</html>
How to Loop YouTube Video in HTML Format
So if you want to loop any video, then you have to add loop=1 and your video will loop until the time you didn’t stop that.
If you use value 0 then the video will play only once, and it’s by default.
But if you use value 1 then the video will be in a loop until the time you stop the video.
<!DOCTYPE html>
<html>
<body>
<iframe width=”450″ height=”370″ src=”https://www.youtube.com/embed/VfnAOeVXgmk?playlist=tgbNymZ7vqY&loop=1″>
</iframe>
</body>
</html>
How to hide YouTube Controls in embedding
If you add controls=0 then the user will not be able to find player controls, but if you change the value from 0 to 1 then the user can use the controls.
<!DOCTYPE html>
<html>
<body>
<iframe width=”450″ height=”370″ src=”https://www.youtube.com/embed/VfnAOeVXgmk?controls=0″>
</iframe>
</body>
</html>
So, these are the few basics of HTML video embedding, if you like this, then don’t forget to share with your friends and keep tuned with us for more updates.