Last Updated on April 26, 2023 by Roshan Parihar
Definition of HTML5 video tag
HTML5 video element is used to show the video as a media resource on a webpage.
HTML5 video element is used to embed videos in HTML. Display mp4 videos and other format videos using HTML video element on your webpage.
The HTML source tag is used inside the video tag to give the location of the source.
The HTML video tag is the new standard for the videos inside the web pages. The video tag gives you many controls to play the videos.
video tag is first introduced with the launch of HTML5.
The element first came into existence in 2007 by opera software.
Syntax
1 2 3 4 |
<video controls> <source src="URL of video source file" type="mention the type of file video/webM or mp4 or ogg"> Enter your text here to display when browser does not support the video tag. </video> |
The syntax contains video start and end tag with forward slashes. The source tag located inside the video tag to include the location of the video. Follow the format to the video source you want to use.
1 2 3 4 |
<video width="320" height="240" controls> <source src="../media/birdreaction.mp4" type="video/mp4" autoplay="true"> Your Browser does not support the video element </video> |
Output
Source tag to add video location
The source tag uses src attribute to include the source. The source can any allowed video format. You have to provide the location of the source to include.
The HTML5 video element control attribute
The control attribute of the HTML video tag used to show play controls. The control and details given below:
- Play/pause button to play or pause the video
- Input forward play button to forward or reverse the video when playing.
- Volume button to increase/decrease the volume of the video.
- Fullscreen button to make the video appear to the whole screen.
- Download button used when you want to download the video.
List of allowed HTML Video Formats
Sr. No. | HTML video available formats | Description |
---|---|---|
1 | mp4 | mp4 extension is for including mp4 video files. |
2 | ogg | ogg extension is for including of ogg video files. |
3 | webm | webm extension is for including webm video files. |
The video tag as an HTML5 tag
The video tag is a standard HTML5 tag.
Element Specific Attribute
Sr. No. | HTML Video Attributes | Description |
---|---|---|
1 |
autoplay |
|
2 |
controls |
|
3 |
height |
|
4 |
loop |
|
5 |
muted |
|
6 |
poster |
|
7 |
preload |
|
8 |
src |
|
9 |
width |
|
How to display controls in HTML video
Control attribute of HTML video is used to display all the controls in videos.
All the controls like start/stop, play/pause, increase/decrease volume and downloads. These all controls are useful when you want to control full features of video.
1 |
<video controls> |
1 2 3 4 |
<video width="300" height="300" controls> <source src="../media/birdreaction.mp4" type="video/mp4"/> Your Browser does not support the video element </video> |
Output
Resources and References
1. W3C Specification
2. HTML living standard
3. W3C project using Github