How to embed youtube video in HTML using iframe?

In this post, You’ll learn how to embed a YouTube video into a webpage. To embed a YouTube video in HTML, simply follow the steps listed below.

1. Go to YouTube and open the video you wish to embed.

2. A share button is located just below the video (see the screenshot below). Click on “Share”.

3. Following the share button’s click. A small window will appear (see the screenshot below). There is now an embed option there. Choose “embed” from the menu.

4. When you click the embed button, the iframe code is displayed for you to copy and paste into your HTML file. Just click on “copy” to copy the code and paste it into your HTML file.

Now let’s see an example HTML file. I will paste this code into an HTML file that I created.

<!DOCTYPE html>
        <title>Embedded YouTube video</title>
                margin-left: 28% 
        <iframe width="560" height="315" src="" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Output :

If you want to know about the iframe then here’s the link –

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: