Images & Media
HTML <video> element
Embeds video, optionally with native playback controls, a poster and timed text tracks. Autoplay is subject to browser restrictions. The example uses illustrative local asset paths; supply matching files before running it. Media formats and codecs have their own compatibility. Provide native controls, captions for spoken and important audio information, and an accessible description as appropriate. Autoplay may be blocked. Use source alternatives when needed. It accepts global HTML attributes; individual global features may be inapplicable or restricted.
Formal Syntax & Structure
html syntaxhtml
<video controls src="movie.mp4"></video>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| src | URL | Specifies the resource to load for the given element, such as an image, script or media file. The resource type, loading behavior and security rules depend on the element. |
| crossorigin | enumerated: anonymous, use-credentials | Configures CORS settings for eligible resource requests. anonymous omits cross-origin credentials; use-credentials includes them. Server CORS headers must permit the request when needed. |
| poster | URL | Specifies an image displayed for a video before video frames are shown. It is not an accessible text alternative; provide an accessible media title or description where needed. |
| preload | enumerated: none, metadata, auto | Hints how much audio or video data should be fetched before playback. Browsers may ignore this hint; autoplay can take precedence. |
| autoplay | boolean | Requests that media begin playback without a manual play action. Browsers may block it, especially for audible media; provide controls. |
| playsinline | boolean | Hints that video should play within its element rather than automatically entering a dedicated fullscreen presentation. Browser behavior can vary. |
| loop | boolean | Requests media replay after reaching the end. The effect depends on media playback and user settings; provide controls for stopping repeated content. |
| muted | boolean | Sets the default muted state of a media element. The current muted state can change via user controls or JavaScript. Muted autoplay may still be restricted. |
| controls | boolean | Requests native playback controls for audio or video. It is a boolean attribute; controls="false" still enables it. Provide accessible alternatives if implementing custom controls. |
| width | non-negative integer | Defines element-specific width, commonly in CSS pixels. On images it can establish an intrinsic aspect ratio together with height; on canvas it sets the bitmap width. |
| height | non-negative integer | Sets an element-specific height, commonly in CSS pixels. On images, pair it with width matching the intrinsic aspect ratio to reserve layout space. It is not a CSS length with units. |
Return Value
HTMLVideoElement
Content model: Source elements when no src is supplied, optional tracks and fallback content; no nested audio or video.
Working Example
Example Snippethtml
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>HTML example</title> </head> <body> <video controls width="320" src="lesson.mp4"> <track kind="captions" src="captions.vtt" srclang="en" label="English"> </video> </body></html>Browser Compatibility
Minimum supported versions across modern rendering engines
Chrome
3
Yes
Edge
12
Yes
Firefox
3.5
Yes
Safari
3.1
Yes
Opera
10.5
Yes
Checked desktop BCD snapshot: video element; codec and autoplay policy vary. Versions denote the recorded start of support (≤ means at least that early), not a guarantee of all behavior. Unresolved mirror and preview rows omitted.
HTML Living Standard