
The HTML <video> tag is used to show a video on a website.
Use the <source> tag within <video> to play a video:
Example:
<!DOCTYPE html>
<html>
<body>
<video width="640" controls>
<source src="https://videos.files.wordpress.com/lFj3lsG4/valentines-day-movie_dvd.mp4" type="video/mp4">
</video>
</body>
</html>
Output:
Note: The controls attribute adds video controls, like play, pause, and volume.
To start a video automatically, use the autoplay attribute:
<!DOCTYPE html>
<html>
<body>
<video width="640" autoplay>
<source src="https://videos.files.wordpress.com/lFj3lsG4/valentines-day-movie_dvd.mp4" type="video/mp4">
</video>
</body>
</html>
Output:
Add muted attribute after autoplay attribute to let your video start playing automatically (but muted):
<!DOCTYPE html>
<html>
<body>
<video width="640" autoplay muted>
<source src="https://videos.files.wordpress.com/lFj3lsG4/valentines-day-movie_dvd.mp4" type="video/mp4">
</video>
</body>
</html>
Output:
There are 3 supported video formats for the <video> tag: MP4/MPEG 4 (video/mp4), WebM (video/webm), and Ogg (video/ogg).
Enjoy coding!
Read also: