Using an HTML5 <video> tag for a YouTube video

Are you allowed to do this, and is it valid?

Because isn’t YouTube considered ‘iframe,’ and not ‘HTML5’ video?

<video data-id="M7lc1UVf-VE"></video>
const video = document.querySelector("video");

It all depends on how you want to show the video(s) on the website? If, for example, you would like to display the video(s) as a popup you could use a lightbox pluginn such as Ekko Lightbox which supports Youtube videos as well.

The Validator should tell you that, though it will need to be in a complete working page, not jsfiddle.

I don’t see anything obviously invalid in the html, the only thing I’m not sure about is having a video element with no src attribute or source element nested within.
The src attribute is optional, but that may be on condition that the source is defined in a source element instead. Though I am not certain of this.


You’re absolutely right! I have the feeling that @asasass makes it way to complecated for himself. I just saw the JS on jsfiddle just to show a couple of Videos. Not sure where he/she is after but I’m sure it all can be accomplished way easier

AFAIK, the long-running goal is to have a custom “player” skin around videos that are not hosted on the same domain (i.e. youtube).

Obviously, the easiest approach would be to simply link or embed the videos and let the browsers player do its thing.

Less easy would be to have a custom player for videos hosted on the same domain.

Working with the youtube API has limitations that need to be considered. On top of that are limitations of developing in jsfiddle / blogger instead of a localhost setup.

So yes, it could be easier, but such is the path that has been chosen.


@Mittineague You’re probably completely right but if he/she from the beginning had choosen to tell the complete wishes the entire project would have been up and running allready. The entire video project is allready running for over 25 days I just see in the JS forum.

Edit: Some questions were not even answerd

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.