Categories
HTML

How to Embed an HTML5 YouTube Video Without Using an Iframe?

Spread the love

Sometimes, we want to embed an HTML5 YouTube video without using an iframe.

In this article, we’ll look at how to embed an HTML5 YouTube video without using an iframe.

Embed an HTML5 YouTube Video without Using an Iframe

To embed an HTML5 YouTube video without using an iframe, we can use the embed tag.

For instance, we write:

<div style="width: 200px; height: 200px;">  
  <embed src="https://www.youtube.com/embed/J---aiyznGQ?autohide=1&autoplay=1" wmode="transparent" type="video/mp4" width="100%" height="100%" allow="autoplay; encrypted-media; picture-in-picture" allowfullscreen title="Keyboard Cat">  
</div>

to embed a video from YouTube within a div.

We put the YouTube video embed URL as the value of the src attribute.

Also, we set the allow attribute to allow autoplay, picture-in-picture, and full screen.

Conclusion

To embed an HTML5 YouTube video without using an iframe, we can use the embed tag.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *