Test your skills: Audio and video

The aim of this skill test is to assess whether you understand how to embed video and audio content in HTML.

Note: You can try solutions in the MDN Playground or in an online editor such as CodePen or JSFiddle.

If you get stuck, you can reach out to us in one of our communication channels.

Task 1

In this task, we want you to embed an audio file onto the page. You need to:

  • Add the path to the audio file to an appropriate attribute to embed it on the page. The audio is called audio.mp3, and it available at a path of https://github.com/mdn/learning-area/raw/refs/heads/main/html/multimedia-and-embedding/tasks/media-embed/media/audio.mp3.
  • Add an attribute to make browsers display some default controls.
  • Add some appropriate fallback text for browsers that don't support <audio>.

To get started, you can click "Play" in the code block below to edit the example in the MDN Playground, or download the starting point for this task and work locally in your own editor.

If you make a mistake, you can clear your work using the Reset button in the MDN Playground. If you get really stuck, you can view the solution at the bottom of the section.

html
<h1>Basic audio embed</h1>

<audio></audio>
Click here to show the solution

Your finished HTML should look like this:

html
<h1>Basic audio embed</h1>

<audio
  controls
  src="https://github.com/mdn/learning-area/raw/refs/heads/main/html/multimedia-and-embedding/tasks/media-embed/media/audio.mp3">
  <p>
    Your browser doesn't support HTML audio.
    <a
      href="https://github.com/mdn/learning-area/raw/refs/heads/main/html/multimedia-and-embedding/tasks/media-embed/media/audio.mp3"
      >Download the track here</a
    >
    instead.
  </p>
</audio>

Task 2

In this task, we want you to mark up a slightly more complex video player, with multiple sources, subtitles, and other features besides. You need to:

  • Add an attribute to make browsers display some default controls.
  • Add some appropriate fallback text for browsers that don't support <video>.
  • Add multiple sources, containing the paths to the video files. The files are called video.mp4 and video.webm, and are available at the following paths:
    • https://github.com/mdn/learning-area/raw/refs/heads/main/html/multimedia-and-embedding/tasks/media-embed/media/video.mp4
    • https://github.com/mdn/learning-area/raw/refs/heads/main/html/multimedia-and-embedding/tasks/media-embed/media/video.webm
  • Let the browser know in advance what video formats the sources point to, so it can make an informed choice of which one to download ahead of time.
  • Give the <video> a width and height equal to its intrinsic size (320 by 240 pixels).
  • Make the video muted by default.
  • Display the text tracks contained in the media folder, in a file called https://raw.githubusercontent.com/mdn/learning-area/refs/heads/main/html/multimedia-and-embedding/tasks/media-embed/media/subtitles_en.vtt, when the video is playing. You must explicitly set the type as subtitles, and the subtitle language to English.
  • Make sure the readers can identify the subtitle language when they use the default controls.

To get started, you can click "Play" in the code block below to edit the example in the MDN Playground, or download the starting point for this task and work locally in your own editor.

If you make a mistake, you can clear your work using the Reset button in the MDN Playground. If you get really stuck, you can view the solution at the bottom of the section.

html
<h1>Video embed</h1>

<video></video>
Click here to show the solution

Your finished HTML should look like this:

html
<h1>Video embed</h1>

<video controls width="320" height="240" muted>
  <source
    src="https://github.com/mdn/learning-area/raw/refs/heads/main/html/multimedia-and-embedding/tasks/media-embed/media/video.mp4"
    type="video/mp4" />
  <source
    src="https://github.com/mdn/learning-area/raw/refs/heads/main/html/multimedia-and-embedding/tasks/media-embed/media/video.webm"
    type="video/webm" />
  <track
    kind="subtitles"
    src="https://raw.githubusercontent.com/mdn/learning-area/refs/heads/main/html/multimedia-and-embedding/tasks/media-embed/media/subtitles_en.vtt"
    srclang="en"
    label="English" />
  <p>
    Your browser doesn't support HTML video.
    <a
      href="https://github.com/mdn/learning-area/raw/refs/heads/main/html/multimedia-and-embedding/tasks/media-embed/media/video.mp4">
      Download the track here
    </a>
    instead.
  </p>
</video>