Home > Blockchain >  How do I embed a YouTube video in HTML5 with no errors?
How do I embed a YouTube video in HTML5 with no errors?

Time:11-18

I'm trying to embed some YouTube videos for a portfolio site. I'm using the embed code given by YouTube itself under one of my videos. But when I use it, I get the "Video Unavailable" error message.

Here's the embed code

<iframe width="560" height="315" src="https://www.youtube.com/embed/9ZIgQFKaK4Y" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

This is what you get under the share section, so I assumed it would work. Does anyone know how to solve this?

CodePudding user response:

I believe this is happening because Youtube only allows HTTPS sites to play videos. This means that your web server won't cut it. When I used JSFiddle, I could play the video. So, I recommend using JSFiddle or some other online HTML editor.

CodePudding user response:

Add div tag like this one:

<div >
  <iframe width="560" src="https://www.youtube.com/embed/9ZIgQFKaK4Y"></iframe>
</div>

Then you can add css later. See in this link: https://www.w3schools.com/howto/howto_css_responsive_iframes.asp

  • Related