HTML Dog
Skip to navigation

HTML Tag: video

Video or captioned audio file.

source elements can be used in a video element to point to alternative resources.

track elements can be used to assign text tracks, such as subtitles.

Any additional content is treated as fallback content, that is, content that a browser will call into play if the video fails to work (if the resource isn’t found, or if the browser is too ancient to understand the video element, for example).

Optional Attributes

Attribute Description Possible values
src The location of the video file to be used. URL.
poster An image to act as a holding frame before playback begins. URL.
preload How much the video should be buffered.
  • none: Go steady on the server. Only fetch video data once playback has been invoked.
  • metadata: Fetch metadata, such as duration and dimensions, and maybe even a cheeky frame or two.
  • auto: User comes before server — download the whole lot before playback even begins, if necessary.
autoplay Annoys the user by automatically playing the video on loading. None.
loop Constantly replays the video once it has finished. None.
muted Mutes the video resource by default. None.
controls Instructs the browser to apply its own in-built set of user controls (to stop, play, mute, etc.). None.
mediagroup Groups together several video and/or audio elements. Those elements sharing the same mediagroup value become part of the same group. Text.
width The width of the video in pixels. This can also be done, or overridden, with CSS. Number.
height The height of the video in pixels. This can also be done, or overridden, with CSS. Number.
crossorigin Used in conjunction with JavaScript to determine how Cross Origin Resource Sharing requests are handled.
  • anonymous
  • use-credentials
Global attributes

Example


<video src="kitties.mp4" width="300" height="200" loop controls poster="kittiesTitle.jpg">
    <img src="hahahaha.jpg" alt="Hilarious cat and caption saying 'soz'.">
</video>