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
widthandheightattributes controls the size of the video player, - The
srcattribute is the link to the YouTube video. - The link should be in the following format:
https://www.youtube.com/embed/idwhere id is the id of the video, it's not the usual link in YouTube you will need to modify it!
Challenge
EasyCreate 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>