HTML4 HTML5
The <video> tag is used to embed a video player directly into a web page. It allows playback of video files and animations without needing external plugins.
Inside the <video> tag, you can place one or more <source> tags specifying video files in various formats (e.g., MP4, WebM, Ogg), allowing the browser to choose the first supported format. Text placed inside the element will only be displayed in browsers that do not support video playback.
Both opening and closing tags are required.
Attributes:
src – path to the video file (can be provided directly in the <video> tag or via child <source> tags).controls – adds a user interface with play, pause, progress bar, and volume controls.width – specifies the width of the player in pixels.height – specifies the height of the player in pixels.autoplay – automatically starts video playback once the page loads (browsers often require audio to be muted for this to work).muted – mutes the video audio by default.loop – automatically restarts video playback after it ends.poster – URL to an image displayed before the video is played (thumbnail).preload – informs the browser how to handle preloading the file before playback (auto, metadata, none).class, id, and style are also supported.In the example below, the <video> tag defines a video player with controls enabled (play buttons) and a preview image (thumbnail):
Code:
The browser will interpret this code as follows: