Lesson 10 / 30

Audio & Video

Play audio and video natively with the video and audio elements, controls and multiple source formats.

video and audio tags

The controls attribute shows play/pause/volume UI without any JavaScript.

<video controls width="320">
  <source src="movie.mp4" type="video/mp4">
  Your browser doesn't support video.
</video>

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

Multiple sources = fallback

Add several <source> tags with different formats — the browser plays the first one it supports.

Quick check: Which attribute shows built-in play/pause controls?

  • controls
  • autoplay
  • loop
  • muted
Answer

controls — `controls` adds the browser's default playback UI.