Articles → HTML 5 → Video Tag In Html5
Video Tag In Html5
Purpose
Syntax
<video controls or autoplay>
<source src=" " type=" " />
<source src=" " type=" " />
</video>
- You can either mention controls or autoplay attribute in video tag.
- Controls attribute adds controls like play, pause and volume.
- Autoplay attribute plays the video automatically when the page gets loaded.
- Source tag is used to mention the video path in ‘src’ attribute and the supporting media format in ‘type’ attribute. You can add as many source tag inside video tag as many you want. HTML 5 will take the first video that is supported by the browser and play it.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
</head>
<body>
<video controls>
<source src="test.mp4" type="video/mp4" />
</video>
</body>
</html>
Click to Enlarge
Browser Support
Browser | MP4 | WebM | Ogg |
---|
Internet Explorer | YES | NO | NO |
Chrome | YES | YES | YES |
Firefox | YES | YES | YES |
Safari | YES | NO | NO |
Opera | YES (from Opera 25) | YES | YES |