How To Add a YouTube Video to Your Web Site

Playing a YouTube Video in HTML

How To Add a YouTube Video to Your Web Site

Playing a YouTube Video in HTML

To play a youtube video on a web page, do the following steps:

  • Upload the video to your YouTube channel
  • Take a note of the video id embedded tab
  • Define an <iframe> element in your web page with height and width
  • Let the src attribute point to the video URL
  • Use the width and height attributes to specify the dimension of the player
  • Add any other parameters to the URL (see below)
<!DOCTYPE html>
<html>
<body>
<iframe width="500" height="300" src="https://www.youtube.com/embed/videoid">
</iframe>
</body>
</html>

 

YouTube - Autoplay

<!DOCTYPE html>
<html>
<body>
<iframe width="500" height="300" src="https://www.youtube.com/embed/videoId?autoplay=1">
</iframe>
</body>
</html>

 

YouTube Loop

<!DOCTYPE html>
<html>
<body>
<iframe width="500" height="300" src="https://www.youtube.com/embed/videoId?playlist=playlistId&loop=1">
</iframe>
</body>
</html>
Top