HTML

HTML Media Tag


9. Media Tag 

  • <audio>: An HTML5 element used to embed audio content on a webpage. It supports various audio formats and provides controls for playback.                               
  • <video>: An HTML5 element used to embed video content on a webpage. It supports multiple video formats and provides controls for playback.                                           
  • <source>: An HTML5 element used within <audio> and <video> elements to specify alternative media resources. It allows browsers to choose the most suitable format for playback.    
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Audio and Video Example</title>
</head>
<body>

<!-- Example of using the <audio> element -->
<audio controls>
    <!-- Using <source> for multiple audio formats -->
    <source src="audio_example.mp3" type="audio/mp3">
    <source src="audio_example.ogg" type="audio/ogg">
    Your browser does not support the audio element.
</audio>
<br>

<!-- Example of using the <video> element -->
<video width="400" height="300" controls>
    <!-- Using <source> for multiple video formats -->
    <source src="video_example.mp4" type="video/mp4">
    <source src="video_example.webm" type="video/webm">
    Your browser does not support the video element.
</video>

</body>
</html>