What is the best way to insert videos from youtube using the tag? How Can I achieve it?
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.
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>
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>