👀 Live Preview
Native video player with controls:
Press play to watch the sample video.

By the end of this tutorial, you’ll confidently embed video in web pages with native HTML5 controls, attributes, and accessibility features.
Use video, source, and controls.
autoplay, loop, muted, preload, poster.
MP4 and WebM with nested source elements.
Add captions with the track element.
Scale players across screen sizes with CSS.
Self-hosted files vs third-party embeds.
<video> Tag?The <video> element is an HTML5 tag designed to embed video content directly in a web page. Browsers provide a built-in player with play, pause, volume, and fullscreen controls when you add the controls attribute.
Modern browsers play MP4 and WebM files natively. Pair <video> with <source> for format fallbacks and include fallback text for very old browsers.
Specify video dimensions, enable controls, and point to a source file:
<video width="640" height="360" controls>
<source src="your-video.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>width and height set the player size and help prevent layout shift while loading.controls adds the native playbar (play, pause, volume, timeline).<source> specifies the file URL and MIME type.video tags for unsupported browsers.| Attribute | Example | Purpose |
|---|---|---|
controls | controls | Show native player UI |
src | src="video.mp4" | Single file on video element |
poster | poster="thumb.jpg" | Thumbnail before playback |
autoplay | autoplay muted | Auto-start (usually needs muted) |
loop | loop | Restart when finished |
preload | metadata, none, auto | Buffering behavior |
muted | muted | Start without sound |
playsinline | playsinline | Inline playback on iOS |
<video> vs <iframe>| Approach | Best For | Notes |
|---|---|---|
<video> | Your own MP4/WebM files | Full control, native player |
<iframe> | YouTube, Vimeo, etc. | Third-party hosted players |
<track> | Subtitles inside video | WebVTT caption files |
Common <video> attributes for playback control and performance:
controls BooleanDisplays the browser’s native video player controls.
<video controls>autoplay BooleanStarts playback automatically. Pair with muted — browsers block unmuted autoplay.
autoplay muted playsinlineloop BooleanRestarts the video when it reaches the end.
<video loop>preload Enumnone, metadata, or auto — how much to buffer before play.
preload="metadata"poster URLImage shown before the user presses play.
poster="/images/preview.jpg"width / height PixelsSet player dimensions to reserve space and reduce layout shift.
width="640" height="360"<video width="640" height="360" controls loop preload="metadata">
<source src="your-video.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>Avoid autoplay with sound unless the user expects it. Always provide controls so viewers can pause.
Basic embedding, looping playback, and subtitles with WebVTT tracks using project sample files.
Native video player with controls:
Press play to watch the sample video.
Use <video> for tutorials, product demos, background loops, and accessible content with captions.
The primary use: embed a video file with native browser controls.
<video width="800" height="450" controls>
<source src="/video/count.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>The loop attribute causes the video to restart once it ends.
<video width="640" height="360" controls loop>
<source src="/video/count.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>Enhance accessibility by including subtitles or captions with a WebVTT file.
<video width="640" height="360" controls>
<source src="/video/count.mp4" type="video/mp4">
<track kind="subtitles" label="English" src="/video/count.vtt" srclang="en" default>
Your browser does not support the video tag.
</video>Make videos scale on smaller screens with CSS:
video {
width: 100%;
max-width: 640px;
height: auto;
border-radius: 8px;
}Set width and height attributes on the element for aspect-ratio hints, then let CSS scale down on mobile.
<track kind="captions"> for spoken content.video for unsupported browsers.poster thumbnails with meaningful alt context nearby.Define sources, controls, and optional track captions.
Picks the first playable source format and buffers per preload.
Native controls handle play, pause, volume, fullscreen, and captions.
Video plays directly in the page without plugins or third-party scripts.
The <video> tag is supported in all modern browsers. Internet Explorer 9+ has partial support.
Chrome, Firefox, Safari, and Edge all play MP4 natively. Provide WebM as a fallback via multiple source elements when needed.
Bottom line: Ship MP4 video with controls and optional WebVTT captions in all browsers your users run today.
The HTML <video> tag is a versatile tool for integrating multimedia into web projects. By understanding syntax, attributes, captions, and responsive design, you can create engaging, accessible video content for your audience.
video elementcontrols so users can pause and adjust volumetrack for accessibilitywidth and height to prevent layout shifttype on source elementsvideo for YouTube URLs (use iframe instead)<video>Bookmark these before you embed your next clip.
<video controls> embeds video without plugins.
Point to MP4/WebM files with MIME types.
EssentialUse muted for autoplay; browsers block sound.
Add track with WebVTT for accessibility.
Scale with max-width: 100% on mobile.
<video> element embeds video content in a web page with a native browser player when controls is present.video/mp4) is widely supported. WebM works in most modern browsers. Offer both via multiple source elements.muted autoplay for silent background clips.<track> element with kind="subtitles" and a .vtt file inside video.iframe for YouTube and Vimeo. Use video for files you host directly (MP4, WebM).Practice the <video> tag with controls and captions in the Try It editor.
5 people found this page helpful