Here is the code I entered in my HTML
<iframe width="640" height="360" src="https://www.youtube.com/watch?v=ZwKhufmMxko">
</iframe>
The video frame will show, but the actual video won't load or even show up. I have tried waiting, so it shouldn't be a loading issue.
I also am currently only using HTML and CSS
Any ideas on how I can get this to work?
On a computer, go to the YouTube video or playlist you want to embed. From the list of Share options, click Embed. From the box that appears, copy the HTML code. Paste the code into your website HTML.
If you receive the error message, "Embedding disabled on request” ,you have probably accidentally disabled embedding via YouTube. To grant permission again, follow these steps: Go to “Video Manager.” Select the appropriate video and click “Edit”.
HTML object tagYou can embed youtube video in html without iframe tag. You can use HTML object tag to embed multimedia (like audio, video, Java applets, ActiveX, PDF, and Flash) in your web pages.
To embed a video in an HTML page, use the <iframe> element. The source attribute included the video URL. For the dimensions of the video player, set the width and height of the video appropriately. The Video URL is the video embed link.
YouTube doesn't allow 3rd parties to embed their site directly like that. Using
<iframe width="640" height="360" src="https://www.youtube.com/watch?v=ZwKhufmMxko">
</iframe>
will raise an error Refused to display 'https://www.youtube.com/watch?v=ZwKhufmMxko' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
to indicate this (you should really check the console for these things).
Fortunately Youtube offers the "embed video" option, which you need to use in order to embed videos.
Your linked video for example would produce the iframe code:
<iframe width="560" height="315" src="https://www.youtube.com/embed/ZwKhufmMxko" frameborder="0" allowfullscreen></iframe>
Change watch?v=
to embed/
The easiest way to get the correct link is to right-click
on the YouTube video and select copy embed code
.
<iframe width="854" height="480" src="https://www.youtube.com/embed/ZwKhufmMxko" frameborder="0" allowfullscreen></iframe>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With