Open In App

What are different video formats supported by browsers in HTML ?

In this article, we will see what are the different video formats that are supported by the browser, along with understanding their implementation.

Browsers support text in different colors with different fonts and along with supporting various media which includes images, music, videos, animations, etc. A video exists in different formats such as MP4, MPEG, WebM, Ogg, AVI, QuickTime, etc. But HTML supports only 3 types of video formats, which include MP4, Ogg, and WebM. 



We will explore all those types of video formats that are supported by the browsers in detail.

<video>: The <video> element in HTML is used to show a video on a webpage. 



Syntax:

<video controls="controls">
    <source src="filename" 
            type="type_of_file">
</video>

Properties Values:

Supported Video Formats:

Example 1: This example describes the various video formats supported by the browser. Here, we have used the .mp4 video format with the <video> element having a control option to play and pause the video.




<!DOCTYPE html>
<html>
  
<head>
    <title>
        Various video formats supported by the Browser
    </title>
</head>
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h3>MP4 video in webpage</h3>
        <video width="500" 
               height="200" controls>
            <source src="gfg.mp4" 
                    type="video/mp4">
        </video>
    </center>
</body>
</html>

Output:

 

Example 2: In the below example, we uploaded a .ogg formatted video file which will be auto-played and muted, by default, into a webpage using <video> element. So, the video in the webpage won’t contain controls to play/pause and audio as muted property is set in <video> element.




<!DOCTYPE html>
<html>
  
<head>
    <title>
        Various video formats supported by the Browser
    </title>
</head>
  
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h3>OGG video in webpage</h3>
        <video width="400" 
               height="250" autoplay muted>
            <source src="gfg.ogg" 
                    type="video/ogg">
        </video>
    </center>
</body>
</html>

Output

 

Example 3: In this example, we have inserted a video into a webpage of the type WebM and should be played on mute, by default, but the user can unmute it if they want. This can be achieved by passing controls, and muted properties to the <video> element.




<!DOCTYPE html>
<html>
  
<head>
    <title
        Various video formats supported by the Browser
    </title>
</head>
  
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h3>WebM video in webpage</h3>
        <video width="200" 
               height="180" controls muted>
            <source src="river_video.webm" 
                    type="video/webm"
        </video>
    </center>
</body>
</html>

Output

 


Article Tags :