top of page
Writer's pictureThe Tech Platform

How to Add Youtube Video in HTML

You can use this id to add videos directly from the Youtube. You can let your video start playing automatically when a user visits the page, by adding autoplay=1 to the YouTube URL.


If you will add mute=1 after autoplay=1 , your video will start playing automatically (but muted).


Attributes:

  1. iframe

  2. src

  3. width

  4. height

  5. autoplay

  6. mute


Add Youtube Video

To add Youtube video in HTML, you have to the embed the video URL code and do Copy and Paste . Then only you will be able to add the video . Otherwise, it will show you error.


Consider the below example :

<!DOCTYPE html>
<html>
<body>

<iframe width="420" height="345" src="https://www.youtube.com/embed/Ef9s0Vfo9cs">
</iframe>

</body>
</html>

Output:





Add YouTube Video using autoplay=1 and mute=1.


In the above, You have seen the output. The video is paused / stop. You have to click in the video then it will run.


But, if you need that whenever you see the result, video should automatically run. In that situation we use autoplay=1 and if you want to make it mute then you use mute=1.


Below is the example where we use autoplay=1 and mute=1.

<!DOCTYPE html>
<html>
<body>

<iframe width="420" height="345" src="https://www.youtube.com/embed/Ef9s0Vfo9cs?autoplay=1&mute=1">
</iframe>

</body>
</html>

Output:




Sofia Sondh

The Tech Platform

1 comment

1 Comment


xojeso7149
Aug 28, 2023

Wow, what a great article, you have no idea how much you are doing for people, ordinary users, I have been looking for this information in a normal way for a very long time, and your video is a fairy tale, there are no complaints here, although I always try to find minuses, but to my surprise there are none here. Everything is just great, I repeat, you are real wizards who helped a user like me to understand such a complex topic, thank you very much and I will look forward to new articles.

Like
bottom of page