Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML HTML Video and Audio Media Basics The Source Element

Video not working

<video src="https://www.youtube.com/watch?v=SZjyk4fak2s" controls /> This is my video tag. But when I preview the video does not come up! Please help and explain why it is not working

1 Answer

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there! As I understand it, YouTube does not support the playback of videos in this manner. To show the video you need to create an IFrame and have it play back the video with the code gotten from the video on YouTube. To do this, right-click the video in question and then copy the "embed code".

This should work for you:

 <iframe width="600" height="400" src="https://www.youtube.com/embed/SZjyk4fak2s" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

Hope this helps! :sparkles: