HTML

How to Display Video and Audio in HTML Without Plugins

How to play video and audio on a web page with the built-in HTML5 <video> and <audio> tags: no Flash, no plugins.

RazakTerra
Reading time
2 min read
Comments
Discussion
How to Display Video and Audio in HTML Without Plugins
On this page
  1. Adding Video
  2. Important Video Attributes
  3. Adding Audio
  4. Quick Tips

Adding Video

The basic structure looks like this:

HTML
<video controls width="640">
  <source src="video.mp4" type="video/mp4" />
  <source src="video.webm" type="video/webm" />
  Your browser does not support the video tag.
</video>
  • <video> → the main container
  • <source> → lets you provide different formats for better browser support
  • The text at the bottom appears only if the browser can’t play the video

Important Video Attributes

Attribute What it does
controls Shows play, pause, volume, and fullscreen
autoplay Starts playing automatically
muted Starts with sound off (needed for autoplay in most browsers)
loop Replays the video when it finishes
poster Shows an image before the video plays
width Sets the display width

Example with more attributes:

HTML
<video controls autoplay muted loop poster="thumbnail.jpg" width="640">
  <source src="video.mp4" type="video/mp4" />
  <source src="video.webm" type="video/webm" />
  Your browser does not support the video tag.
</video>

Note: Most browsers block autoplay with sound, so you usually need to add muted if you want it to start automatically.

Adding Audio

The audio tag works in a similar way:

HTML
<audio controls>
  <source src="audio.mp3" type="audio/mpeg" />
  <source src="audio.ogg" type="audio/ogg" />
  Your browser does not support the audio tag.
</audio>

Common attributes for audio:

  • controls → shows the player controls
  • autoplay → starts playing automatically
  • loop → repeats the audio
  • muted → starts with sound off

Quick Tips

  • Always include more than one <source> format when possible (MP4 + WebM is a good combo).
  • Use controls so users can play and pause the media.
  • Add a poster image for videos so the area doesn’t look empty before playing.
  • Be careful with autoplay, many users find it annoying.
  • Compress your video and audio files to keep the page loading fast.

With the <video> and <audio> tags, you can add media to your pages easily without relying on any external plugins.

Written by

Razak

Writes about the web, slowly, and builds small tools on the side.

Discussion

Comments

Loading comments…

Keep reading