#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
5 min read
•Question 17 of 49easy

How to Embed Audio and Video?

Native multimedia in HTML5.

What You'll Learn

  • Video and audio elements
  • Key attributes
  • Multiple format support

Native Multimedia

HTML5 introduced <audio> and <video> elements for native multimedia without plugins like Flash.

Key Attributes

AttributePurpose
controlsShows play/pause/volume
autoplayStarts automatically (often blocked)
mutedStarts muted
loopRepeats playback
posterVideo thumbnail

Video Examples

index.htmlHTML
<!-- Video with controls -->
<video controls width="640" poster="thumbnail.jpg">
  <source src="video.mp4" type="video/mp4">
  <source src="video.webm" type="video/webm">
  Your browser doesn't support video.
</video>

<!-- Autoplay muted (for autoplay to work) -->
<video autoplay muted loop playsinline>
  <source src="background.mp4" type="video/mp4">
</video>

Audio Examples

index.htmlHTML
<!-- Audio player -->
<audio controls>
  <source src="song.mp3" type="audio/mpeg">
  <source src="song.ogg" type="audio/ogg">
  Your browser doesn't support audio.
</audio>

Format Support

  • Video: MP4 (widest), WebM, Ogg
  • Audio: MP3, WAV, Ogg

Provide multiple formats for browser compatibility.