HTML Video

HTML Tutorial

HTML Video

The <video> element in HTML is used to embed video content directly on web pages. It supports multiple formats and allows users to play, pause, and control the video using built-in browser controls.


Basic Syntax


 

  • <source> → Specifies the video file and format.

  • controls → Displays playback controls (play, pause, volume).

  • Fallback text is shown if the browser does not support the video element.


Video Attributes

AttributeDescription
controlsShow play, pause, volume, and other controls
autoplayStart playing the video automatically (muted required in modern browsers)
loopPlay the video continuously
mutedStart the video muted
posterImage displayed before video starts
width / heightSet video dimensions
preloadHow the video should be loaded (auto, metadata, none)

Example: HTML Video with Attributes


 

Explanation:

  • Video starts autoplay, loops, and is muted by default.

  • poster="poster.jpg" → Shows an image before video playback.

  • Multiple sources ensure cross-browser compatibility.


Key Points

  • Modern HTML5 <video> eliminates the need for Flash plugins.

  • Use multiple formats (.mp4, .webm, .ogg) for full browser support.

  • Always provide controls for better user experience.

  • autoplay videos often need muted to work on mobile browsers.

You may also like...