HTML <video> Tag

Beginner
7 min read
Updated: Nov 2026
4 examples
Live preview

Definition and Usage

The <video> element embeds a video player in a document. Point to a file with src or nested <source> elements; the browser picks a format it can play.

Add controls for a native player, poster for a preview image, and <track> for captions. Put fallback text (and download links) between the tags for unsupported browsers. For sound-only media, prefer <audio>.

Baseline · Widely available.

Not deprecated. Core support has been stable across browsers since about July 2015. Some attributes (for example loading) still vary.

Autoplay warning.

Unmuted autoplay is often blocked. Prefer user-started playback with controls. If you must autoplay, start muted (and often playsinline on mobile).

Experimental / uneven extras.

loading="lazy", controlslist, and Picture-in-Picture / remote-playback flags are newer or inconsistently supported — treat them as progressive enhancements.

HTML Syntax

syntax.html
<video src=" url" controls width="320">fallback</video>

Both start and end tags are required. Without controls (or custom UI via JavaScript), most users have no useful player. Set width and height (CSS pixels) to reserve space and reduce layout shift.

Attributes

The attributes you will use most often on <video>:

AttributeDescriptionTry it
srcURL of a single video file. Optional if you use nested <source> elementsTry it
controlsShows the browser’s default play, pause, seek, volume, and fullscreen UITry it
posterImage shown before the first frame is availableTry it
width / heightDisplay size in CSS pixels (no percentages). Helps avoid layout shiftTry it
loopRestarts playback when the video endsTry it
mutedStarts silent. Presence means muted — remove the attribute to unmute by defaultTry it
autoplayStarts as soon as possible. Often blocked unless muted or after user gestureTry it
preloadHint: none, metadata (common advice), or auto. Browsers may ignore itTry it
playsinlinePrefer inline playback (important on many mobile browsers) instead of forcing fullscreenTry it
crossoriginCORS mode for the media request (anonymous or use-credentials)Try it
controlslistHints which native controls to hide (e.g. nodownload). Support variesSee edge cases

Global Attributes

The <video> tag also supports the Global Attributes in HTML.

Live Preview

Toggle controls, loop, and muted on a real <video> element.

A real <video> using /video/count.mp4. Toggle chips, then press Apply (or the chip itself).

Player

controls on · loop off · muted off

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Basic Player with Controls

Embed one file, reserve size, and show the native player UI.

HTML
<video
  src="/video/count.mp4"
  width="360"
  height="203"
  controls
  preload="metadata"
>
  Your browser does not support the video element.
  <a href="/video/count.mp4">Download MP4</a>.
</video>
Try It Yourself

How It Works

  1. Set src to the video URL (here /video/count.mp4).
  2. Add controls so users can play, pause, seek, and change volume.
  3. Set width / height to reserve layout space.
  4. Write fallback text inside the tags for browsers without <video>.

Example 2 — Multiple Formats with <source>

Offer more than one format so the browser can choose what it supports.

HTML
<video controls width="360" height="203" preload="metadata">
  <source src="/video/count.webm" type="video/webm">
  <source src="/video/count.mp4" type="video/mp4">
  <p>
    Download
    <a href="/video/count.webm">WEBM</a>
    or
    <a href="/video/count.mp4">MP4</a>.
  </p>
</video>
Try It Yourself

How It Works

  1. Omit src on <video> when using nested sources.
  2. List <source> elements with src and a useful type MIME hint.
  3. Browser order: it tries sources top to bottom until one is playable.
  4. Keep a download fallback inside for unsupported clients.

Example 3 — Poster Image and Muted Autoplay

Show a preview frame, then start muted when the browser allows autoplay.

HTML
<video
  src="/video/count.mp4"
  width="360"
  height="203"
  controls
  poster="/images/apple.png"
  muted
  autoplay
  playsinline
  preload="metadata"
>
  <a href="/video/count.mp4">Download MP4</a>
</video>
Try It Yourself

How It Works

  1. poster shows an image until a video frame is ready.
  2. muted + autoplay is the pattern most likely to be allowed.
  3. playsinline prefers in-page playback on many phones.
  4. Keep controls so users can unmute, pause, or replay.

Example 4 — Captions with <track>

Attach a WebVTT file so users can enable subtitles from the player.

HTML
<video controls width="360" height="203" preload="metadata">
  <source src="/video/count.mp4" type="video/mp4">
  <track
    kind="subtitles"
    src="/video/count.vtt"
    srclang="en"
    label="English"
    default
  >
  <a href="/video/count.mp4">Download MP4</a>
</video>
Try It Yourself

How It Works

  1. Provide a media source (src or <source>).
  2. Add <track> pointing at a .vtt file.
  3. Set kind, srclang, and label so the player can list the track.
  4. Optional default selects that track when the browser supports it.

Edge Cases & Pitfalls

Most video bugs come from autoplay policy, missing controls, format support, or layout shift.

ux

Always give a way to play and stop

Without controls (or custom UI), users may see a blank box with no player. Prefer visible controls.

policy

Unmuted autoplay is unreliable

Browsers often require a user gesture. Prefer opt-in play; use muted autoplay (plus playsinline on mobile) only when necessary.

layout

Set width and height

Explicit dimensions (or CSS aspect-ratio) reduce layout shift. Especially important if you use lazy loading.

formats

Not every codec works everywhere

Offer multiple <source> formats (commonly WebM plus MP4).

a11y

Captions need a track file

Use <track> + WebVTT for timed text. Also provide a transcript when speech is important.

api

muted="false" does not unmute

Boolean attributes: if muted (or autoplay) is present, it is on. Remove the attribute to turn it off.

hint

controlslist is only a hint

Values like nodownload may hide UI in some browsers but are not a security boundary — users can still obtain the file URL.

Browser Support

The <video> element is core HTML media in every modern browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<video>

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support the element; codec support, autoplay rules, and extras like controlslist still differ by browser and OS.

97% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer 9+
Partial
<video> Widely supported

Bottom line: Safe to use with controls, dimensions, and a format fallback. Treat autoplay, controlslist, and loading="lazy" as progressive extras.

Key Takeaways

  • Role: <video> embeds video; controls gives users a real player.
  • Formats: use nested <source> when one codec is not enough.
  • Autoplay: prefer user play; muted + playsinline when you must autoplay.
  • Access: dimensions, poster, captions via <track>, and a download fallback.

One line: a good <video> has a playable source, controls, size, and a simple fallback.

Default CSS Settings

Typical user-agent styling for video (exact chrome varies by browser):

default.css
video {
  object-fit: contain;
}

video:not([controls]) {
  /* without controls, many UAs still show the video box */
}

You can style the outer box (width, max-width, border-radius). Use CSS object-fit and object-position to fit the picture inside the frame. Individual control chrome is browser-specific.

Frequently Asked Questions

The video element embeds a media player for video (and can play audio). With the controls attribute, the browser shows a native UI for play, pause, seek, volume, and fullscreen — no plugin required.
Use src on video for one file. Use nested source elements when you offer multiple formats (for example WebM and MP4); the browser picks the first format it can play.
Most browsers block autoplay with sound. Prefer controls and a user play action. If you must autoplay, start muted (and often playsinline on mobile) so playback is more likely to be allowed.
Set the poster attribute to an image URL. Until the first frame is ready, the poster is shown. Set width and height to avoid layout shift.
Nest a track element that points to a WebVTT (.vtt) file, with kind, srclang, and label. Users can enable captions from the player menu when supported.
No. muted is a boolean attribute: if it is present, the video starts muted. Remove the attribute entirely to start unmuted.

Next: wbr

Suggest optional line-break opportunities with the HTML wbr element.

wbr tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

15 people found this page helpful