Video & Audio

The video Element

Example

controls adds play/pause and volume buttons. Offer several <source> formats; the browser uses the first one it supports:

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
</head>
<body>

<video width="320" height="180" controls poster="https://picsum.photos/id/1043/320/180">
  <source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm" type="video/webm">
  <source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video>

</body>
</html>

Result

Video Attributes

AttributeEffect
controlsshows playback controls
autoplaystarts automatically (browsers only allow this with muted)
muted, loopno sound / repeat
posterimage shown before playback
playsinlineplays inside the page on iPhones instead of full screen

The audio Element

Example

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
</head>
<body>

<audio controls>
  <source src="https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

</body>
</html>

Result