Video


Video

Video is included in online documents using the HTML < video > element. It could have one or more video sources, which would be indicated by the src property or the source element. All current browsers recognise the < video > element. Not all browsers, however, support the same video file format.

To play a video file on the webpage, we can use the < video> element. The file formats which can be used are MP4, WEBM, OGG. The attributes which can be used with the < video> tag are as follows:

  • controls

    used to add controls to the video like play,pause

  • height

    used to specify the height of the video player

  • width

    used to specify the width of the video player

  • autoplay

    used to play the video as soon as it is executed

  • muted

    used to mute the video

  • oop

    used to play the video repeatedly

  • src

    used to specify the source url of the file

How Does It Work?

Video controls, such as play, pause, and volume, are added with the controls attribute.

Always include width and height attributes in your code. The page may flicker while the video loads if the height and width are not specified.

You can use the < source > element to specify other video files for the browser to choose from. The browser will use the first format it recognises.

Only browsers that do not support the < video > element will see the text between the < video > and < /video > tags.

Example No:

<html> <body> <h1>Knowledge2life</h1> <video width="320" height="240" controls> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> </video> </body> </html>

OUTPUT:

Knowledge2life