Tsallaka zuwa abun ciki
Justice Tech School

Audio and Video

The video and audio elements play media with the controls attribute for play, pause and volume. Give several source files in different formats so every browser can play one.

Add captions with a track element, set a poster image for video, and never autoplay with sound because it annoys people.

Example
<video controls width="320" poster="">
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.webm" type="video/webm">
  <track kind="captions" src="captions.vtt" srclang="en" label="English">
  Your browser does not support video.
</video>

<audio controls>
  <source src="song.mp3" type="audio/mpeg">
</audio>

Exercise

Show the play and pause buttons.

<audio src="a.mp3" ></audio>

Quiz Test

Which element adds captions to a video?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.