HTML YouTube Videos

To embed a YouTube video in an HTML document, you can use the following code:

<iframe width="560" height="315" src="https://www.youtube.com/embed/VIDEO_ID" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Replace VIDEO_ID with the actual ID of the video you want to embed. You can find the ID in the URL of the video after the v= parameter. For example, if the URL of the video is https://www.youtube.com/watch?v=dQw4w9WgXcQ, then the video ID is dQw4w9WgXcQ.

You can customize the width and height of the video by changing the values of the width and height attributes. You can also customize the options of the video player by adding or removing values from the allow attribute.

Here is an example of how to embed a YouTube video using this code:

<!DOCTYPE html>
<html>
<head>
	<title>My YouTube Video</title>
</head>
<body>
	<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</body>
</html>

This will display the video player on your web page, and allow users to watch the video directly on your site.

You may also like...

Popular Posts

Leave a Reply

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