Menu
Coddy logo textTech

Iframe

Lesson 2 of 7 in Coddy's YouTube Video Player - HTML Project course.

The easiest way to create YouTube player in your website is by using iframe tag:

<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ">
</iframe>

Note couple of things:

  • Declaring width and height attributes controls the size of the video player,
  • The src attribute is the link to the YouTube video.
  • The link should be in the following format:
    • https://www.youtube.com/embed/id where id is the id of the video, it's not the usual link in YouTube you will need to modify it!
challenge icon

Challenge

Easy

Create a YouTube player using an iframe with any video you choose, and add the width and height attributes of your choice.

Try it yourself

<!DOCTYPE html>
<html>
    <body>
        <!-- Write code here -->
    </body>
</html>

All lessons in YouTube Video Player - HTML Project