HTML: video

The <video> element embeds a video player in a page and can provide controls, a poster image, and captions.

What you will learn

Minimal example

<video controls poster="preview.jpg" width="640">
  <source src="lesson.mp4" type="video/mp4">
  Your browser does not support video playback.
</video>

The controls attribute gives users play, pause, and volume controls. Keep the video responsive with CSS such as max-width: 100%.

Add captions

<video controls>
  <source src="lesson.mp4" type="video/mp4">
  <track kind="captions" src="captions.vtt" srclang="en" label="English" default>
</video>

Captions make spoken content available to deaf or hard-of-hearing users and help people watching without sound.

Autoplay and accessibility

Autoplay can be disruptive and is often blocked unless the video is muted. Do not autoplay important content without user control. Provide a pause mechanism and avoid flashing content.

Common mistakes