Embedding a video from YouTube is quite simple. In this post, I’ll show you how to embed YouTube video in HTML.
Time needed: 2 minutes.
- Go to YouTube and select the video you want to embed.
- From the options in the bottom of the video, select SHARE.
- Select Embed from the box that appears.
- From the next popup, select appropriate options and copy the HTML code.
- Paste the code in your HTML code.
This is the code i have copied. Place it in your HTML page.
<iframe width="560" height="315" src="https://www.youtube.com/embed/8S_nSP76YGE" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
You can also embed youtube video in HTML using <object> and <embed> tag as shown below.
Note: Using <object> and<embed> is deprecated.
<object width="420" height="315" data=" https://www.youtube.com/embed/8S_nSP76YGE"> </object>
<embed width="420" height="315" data=" https://www.youtube.com/embed/8S_nSP76YGE"> </embed>
If you enjoyed this post, let me know by leaving a comment below.