HTML Video
Subject: html
🎥 HTML <video> Element
The HTML5 <video> element allows you to embed video files directly into web pages — no Flash or third-party plugins needed.
✅ Why Use <video>?
- ✅ Native browser support — works on all major browsers
- 🎛️ Customizable controls — play, pause, volume, fullscreen
- 🔁 Multiple formats — fallback support for compatibility
- ♿ Accessibility — supports captions via
<track>
🧱 Basic Syntax
🛠️ Common <video> Attributes
controls: displays play/pause, volume, fullscreen controlsautoplay: starts playing video automaticallymuted: mutes the video on load (required for autoplay)loop: repeats video once it endsposter: displays an image before video playswidth&height: sets the player dimensions
📦 Example: Basic Video Player
🖼️ Example: Poster + Autoplay
poster: preview image before video startsautoplay: plays automatically on page loadmuted: required for autoplay to work in modern browsers
💬 Adding Captions with <track>
- The
.vttfile must be in WebVTT format. kind="subtitles"specifies caption type.
🎞️ Supported Video Formats
| Format | Extension | Browser Support |
|---|---|---|
| MP4 | .mp4 | ✅ All major browsers (Recommended) |
| WebM | .webm | ✅ Chrome, Firefox, Edge |
| Ogg | .ogv | ✅ Firefox, Opera |
📌 Key Takeaway
- The
<video>element makes embedding video seamless and plugin-free. - Always use multiple
<source>tags for compatibility. - Use attributes like
controls,autoplay,muted, andposterfor enhanced UX. - Add captions using
<track>to improve accessibility.
Advertisement Slot 1
Advertisement Slot 2