Skip to content

04. Audio Video

HTML5 provides native <audio> and <video> elements for embedding multimedia content without requiring plugins. These elements offer built-in controls, support multiple formats, and provide better accessibility than plugin-based solutions. Understanding how to use audio and video elements is essential for modern web development.

<audio src="audio.mp3" controls></audio>
<audio controls>
<source src="audio.mp3" type="audio/mpeg">
<source src="audio.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>
<audio
src="audio.mp3"
controls
autoplay
loop
muted
preload="auto">
</audio>
<video src="video.mp4" controls width="640" height="360"></video>
<video controls width="640" height="360">
<source src="video.mp4" type="video/mp4">
<source src="video.webm" type="video/webm">
Your browser does not support the video element.
</video>
<video
src="video.mp4"
controls
autoplay
loop
muted
poster="poster.jpg"
width="640"
height="360">
</video>
  • controls: Show playback controls
  • autoplay: Start automatically
  • loop: Repeat playback
  • muted: Start muted
  • preload: Loading strategy
  • poster: Video thumbnail (video only)
<video controls>
<source src="video.mp4" type="video/mp4">
<p>Your browser does not support HTML5 video.</p>
</video>
<video controls>
<source src="video.mp4" type="video/mp4">
<source src="video.webm" type="video/webm">
</video>