How can I insert a YouTube video in HTML? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How can I insert a YouTube video in HTML?

21st Nov 2017, 1:06 AM
LONEWOLF
LONEWOLF - avatar
2 Answers
+ 7
In case you ever forget, just go to the YouTube video you want to use, click the _Share_ link under the video, click the _Embed_ option, and copy the script. You can see this demonstrated in the YouTube Video link I included below, using the embed script from that page. <iframe width="560" height="315" src="https://www.youtube.com/embed/6T8stXj7Dzg?start=14" frameborder="0" allowfullscreen></iframe>
21st Nov 2017, 1:58 AM
David Carroll
David Carroll - avatar
+ 7
To play your video on a web page, do the following: Upload the video to YouTube. Take a note of the video id. Define an <iframe> element in your web page. 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="420" height="345" src="https://www.youtube.com/embed/XGSy3_Czz8k"> </iframe> </body> </html>
21st Nov 2017, 1:10 AM
Rishikesh Dhruva
Rishikesh Dhruva - avatar