HTML Video Element (<video>):

The HTML <video> element is used to embed videos within a web page. Videos are powerful for conveying information, entertainment, or instructional content. Here's a detailed guide on the HTML video element:

  1. Basic Syntax:
    • The <video> element is used to embed a video, and it includes the src attribute specifying the source (URL) of the video.
     <video src="video.mp4" controls></video> 
  2. Source (src) Attribute:
    • The src attribute contains the URL or file path of the video. It can be a relative or absolute path.
  3. Controls Attribute:
    • The controls attribute adds video controls, such as play, pause, and volume, allowing users to interact with the video.
  4. Width and Height Attributes:
    • The width and height attributes can be used to specify the dimensions of the video player.
    <video src="video.mp4" controls "> </video>
    Output:-

  5. Alternative Content:
    • The content within the <video> element serves as alternative content, displayed if the browser does not support the video.
     <video controls width="640" height="360">
       <source src="video.mp4" type="video/mp4">
        Your browser does not support the video tag.
     </video> 
  6. Autoplay and Loop Attributes:
    • The autoplay attribute automatically starts playing the video when the page loads, and the loop attribute makes the video repeat.
    <video src="video.mp4" controls autoplay loop> </video> 
  7. Poster Attribute:
    • The poster attribute specifies an image to be displayed before the video starts playing. It is useful for providing a preview.
    <video src="video.mp4" controls poster="video-preview.jpg"> </video>


Example:
 <!DOCTYPE html>
 <html lang="en">
 <head>
 <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML Video Example</title>
 </head>
 <body>
 <h4>Welcome to My Video Page</h4>
     
  <video src="sample-video.mp4" controls width="640" height="360">
        Your browser does not support the video tag. </video>
         
 <p>This is an example of using the <code>&lt;video&gt;</code> 
    element in HTML to embed a video. The video includes controls for playback.</p>

 </body>
 </html>

Output:- HTML Video Example

Welcome to My Video Page

This is an example of using the <video> element in HTML to embed a video. The video includes controls for playback.