Master AI & Build your First Coding Portfolio with SkillReactor | Sign Up Now

Lesson 3 - Images And Multimedia

3.2 Adding Video And Audio

You can enhance your webpage by incorporating multimedia elements like audio and video using HTML's <audio> and <video> tags. These tags enable you to embed audio and video files directly on your site, allowing users to play them seamlessly.

Adding Audio:

To include audio files, use the <audio> tag. You can also add the controls attribute to provide playback controls such as play, pause, and volume adjustment.

Let's see an example:

<audio src="https://download.samplelib.com/mp3/sample-3s.mp3" controls></audio>

In this example:

  • The src attribute specifies the URL where the audio file is located.
  • The controls attribute adds buttons for users to control playback.

Adding Video:

For integrating videos, utilize the <video> tag. Similarly, include the src attribute to define the source of the video file, and add the controls attribute for playback control buttons.

Here's how you can add a video to your webpage:

<video src="https://download.samplelib.com/mp4/sample-5s.mp4" controls></video>

In this case:

  • The src attribute specifies the URL of the video file.
  • The controls attribute provides users with options to play, pause, adjust volume, and more.

By using these tags and attributes, you can enrich your webpage with engaging audio and video content, enhancing user experience and interaction.