Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

WDS21 - It's All About YouTube

In the last article, we learned about Html videos and how we can add them easily to our web pages. We have seen that it is very difficult and struggle that some browsers do not support specific video format. So to play them in different browsers you any have to add different types of video format and for that, you have to convert videos manually from one format to another. Is there a better option?
Definitely, yes! 
An easier solution is to let Youtube play the videos for you. When you upload(or watch) a video on youtube, you will see that YouTube has the unique id for each video. We can use this id to play video on our web pages and yes, it will play on all the browsers and operating systems. Let's see how we can achieve this...

YouTube Videos

The simplest way to use a YouTube video on the HTML page is to head to any youtube video, right click and select "Copy Embed Code". This will directly copy the required HTML, to use.
Let's see what code looks like:


We can write the same code in simplified format as follows:


 We use the tag to describe the video here with following attributes:
  • width and height : To describe the size of the video
  • src : To describe the source of video(last part of URL is nothing but unique id)
  • frameborder : 0 for no border around video, 1 for border
  • allowfullscreen : Allows the user to watch the video in full screen
  • controls : 1 for showing controls(default), 0 for not showing controls
  • loop: 1 for looing videos, 0 for not(default)
  • Others are less important and browser-specific attributes, so neglect them
That's all for today. Hope you are practicing what you are learning here. In the next article, we will see how we can add other media to HTML pages. Till then #keepCoding.

This post first appeared on The Coding Express, please read the originial post: here

Share the post

WDS21 - It's All About YouTube


Subscribe to The Coding Express

Get updates delivered right to your inbox!

Thank you for your subscription