Embedding a video from YouTube is quite simple. In this post, I’ll show you how to embed YouTube video in HTML.
- 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.
Example
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>
Alternate methods
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>
Subscribe
Join the newsletter to get the latest updates.