
HTML provides several elements for embedding multimedia content into a web page, including audio and video elements.
Audio Element: The <audio>
element is used to embed audio files into a web page. To play the audio, you need to include the src
attribute, which specifies the location of the audio file. Here’s an example:
<audio controls>
<source src="music.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
The controls
attribute adds play, pause, and volume controls to the audio player. You can also include alternative text within the <audio>
element for users with assistive technologies.
Video Element: The <video>
element is used to embed video files into a web page. Similar to the <audio>
element, you need to include the src
attribute to specify the location of the video file. Here’s an example:
<video width="400" controls>
<source src="movie.mp4" type="video/mp4">
Your browser does not support the video element.
</video>
The width
attribute sets the width of the video player, while the controls
attribute adds play, pause, and volume controls to the video player. You can also include alternative text within the <video>
element for users with assistive technologies.
Note: Different browsers support different audio and video formats, so it’s a good idea to include multiple source files in different formats to ensure the content is accessible to the greatest number of users.