Careeroza
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
| Attribute | Effect |
|---|---|
controls | shows playback controls |
autoplay | starts automatically (browsers only allow this with muted) |
muted, loop | no sound / repeat |
poster | image shown before playback |
playsinline | plays 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