Cover Image for How to Embed Youtube Video in Html
88 views

How to Embed Youtube Video in Html

To embed a YouTube video in HTML, you can use the YouTube embed code or the YouTube iframe API. Here’s an example of how to embed a YouTube video using the standard embed code:

  1. Find the YouTube video you want to embed.
  2. Click on the “Share” button below the video.
  3. Click on the “Embed” option.
  4. Copy the provided embed code.

The embed code will look something like this:

HTML<span role="button" tabindex="0" data-code="<iframe width="560" height="315" src="https://www.youtube.com/embed/VIDEO_ID" frameborder="0" allowfullscreen>
<iframe width="560" height="315" src="https://www.youtube.com/embed/VIDEO_ID" frameborder="0" allowfullscreen></iframe>

Replace “VIDEO_ID” in the src attribute with the actual ID of the YouTube video you want to embed. For example, if the video URL is “https://www.youtube.com/watch?v=ABC123”, the video ID is “ABC123”.

Now, you can paste this code into your HTML file where you want the video to appear. Adjust the width and height attributes of the <iframe> element as per your desired dimensions.

Here’s an example of embedding a YouTube video:

HTML
<!DOCTYPE html>
<html>
  <head>
    <title>Embedded YouTube Video</title>
  </head>
  <body>
    <h1>My Webpage</h1>
    <iframe width="560" height="315" src="https://www.youtube.com/embed/ABC123" frameborder="0" allowfullscreen></iframe>
  </body>
</html>

Make sure to replace “ABC123” with the actual video ID you want to embed.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS