Class – 17 | HTML Media Elements (Audio, Video) | HTML Tutorial

HTML Media Elements - Class - 17
HTML Media Elements – Class – 17

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 embeds video files into a web page. Similar to the <audio> component, 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 various formats to ensure the content is accessible to the most significant number of users.

Next Class

Leave a Comment

Your email address will not be published. Required fields are marked *