How to embed an auto-playing YouTube video in an iframe with HTML?

Spread the love

Sometimes, we want to embed an auto-playing YouTube video in an iframe with HTML.

In this article, we’ll look at how to embed an auto-playing YouTube video in an iframe with HTML.

How to embed an auto-playing YouTube video in an iframe with HTML?

To embed an auto-playing YouTube video in an iframe with HTML, we add the allow attribute.

For instance, we write

<iframe
  src="https://www.youtube.com/embed/VIDEO_ID?autoplay=1"
  allow="autoplay"
></iframe>

to set the allow attribute to autoplay and add autoplay=1 to the query string in the video URL to make the video autoplay.

Conclusion

To embed an auto-playing YouTube video in an iframe with HTML, we add the allow attribute.

Leave a Reply

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