What is the best way to insert videos from youtube using the tag? How Can I achieve it?
6 Answers
The simplest way to play videos in HTML, is by using YouTube as a source. First, you should upload the video to YouTube or copy the embed code of an existing video, which will be inserted in a element in your web page. To have the embed link of the YouTube video follow these simple steps: -Open the video on YouTube and click the share button. -Open the Embed code. -Copy the Source link. As you copy the embed link you can insert it into your HTML document as the src of your element. Also define width and height for your video. Now let’s see how it will look like.
-
You can try the examples yourself here : w3docs.com/snippets/html/how-to-insert-video-in-html.html Commented Nov 19, 2019 at 13:05
YouTube gives you the full tag you need to copy.
Go to the video that you want to embed, click Share, click the Embed option, and then copy/paste the iframe code it gives you.
Here is YouTube's help document which tells you how to do it: https://support.google.com/youtube/answer/171780?hl=en
Embed a video
- On a computer, go to the YouTube video you want to embed.
- Under the video, click SHARE .
- Click Embed.
- From the box that appears, copy the HTML code.
- Paste the code into your blog or website HTML.
If you are using latest html5 version then you should use this code. HTML5 can come up with some new tag Video tag are one of them.
<html>
<body>
<video width=auto height=auto controls>
<source src="https://www.youtube.com/embed/W7qWa52k-nE" type="video/mp4">
</video>
</body>
</html>
If you want to use iframe tag you should use this code.
<html>
<body>
<iframe src="http://www.youtube.com/embed/W7qWa52k-nE" width=auto height=auto>
</iframe>
</body>
</html>
-
2Can you link to any YouTube documentation about this? Commented Jan 16, 2020 at 12:46
you can insert video from youtube using the iframe
code
<iframe heigth=200px width=200px src="https://www.youtube.com/watch?v=0z2nE9dMD1s"> </iframe>
You can insert Video in your webpage using iframe.
Follow this step:
Use the youtube site to find the video you want
Click the'Share'button below the video
Click the 'Embed' button next to the link they show you
Copy the iframe code given and paste it into the html of your web page.
Write following code in HTML and paste that link between src attribute.
<html>
<body>
<iframe src="http://www.youtube.com/embed/W7qWa52k-nE"
width="560" height="315" frameborder="0" allowfullscreen></iframe>
</body>
</html>