HTML Video Element

I want to read more about the HTML video element. I am looking into how to make the size responsive.

Date Created:
2 445

References



Related


  • Web Video Text Tracks (WebVTT)
    • WebVTT are text tracks providing specific text cues that are time-aligned with other media, such as video or audio tracks. The WebVTT API provides functionality to define and manipulate these text tracks. The WebVTT API is primarily used for displaying subtitles or captions that overlay with video content, but it has other uses: providing chapter information for easier navigation and generic metadata that needs to be time-aligned with audio or video content.
    • A text track is a container for time-aligned text data that can be played in parallel with a video or audio track to provide a translation, transcription, or overview of the content. A video or audio media element may define tracks of different kinds or in different languages, allowing users to display appropriate tracks based on their performance or needs.
    • The different kinds of text data that can be specified (but not necessarily supported by all browsers) are:
      • subtitles provide a textual translation of spoken dialog. This is the default type of text track, and, if used, the source language must be specified.
      • captions provides transcription of spoken text, and may include information about other audio such as music or background noise. They are intended for hearing impaired users.
      • chapters provide high level navigation information, allowing users to more easily switch to relevant content.
      • metadata is used for any other kinds of time-aligned information.
    • The individual time-aligned units of text data within a track are referred to as "cues". Each cue has a start time, end time, and textual payload
    • The ::cue CSS pseudo-element can be used both in HTML and in a WebVTT file to style the cues for a particular element, for a particular tag within a cue, for a VTT class, or for a cue with a particular label. The ::cue-region pseudo-element is intended for styling cues in a particular region, but is not supported in any browser.
WEBVTT

00:00.000 --> 00:00.900
Hildy!

00:01.000 --> 00:01.400
How are you?

00:01.500 --> 00:02.900
Tell me, is the lord of the universe in?

00:03.000 --> 00:04.200
Yes, he's in - in a bad humor

00:04.300 --> 00:06.000
Somebody must've stolen the crown jewels


Notes


The <video> HTML element embeds a media player which supports video playback into the document. You ca use <video> for audio content as well, but the <audio> element may provide a more a more appropriate user experience.
<video controls width="250">
<source src="/media/cc0-videos/flower.webm" type="video/webm" />
<source src="/media/cc0-videos/flower.mp4" type="video/mp4" />
Download the
<a href="/media/cc0-videos/flower.webm">WEBM</a>
or
<a href="/media/cc0-videos/flower.mp4">MP4</a>
video.
</video>

Similarly to the <img> element, we include a path to the media we want to display inside the src attribute; we can include other attributes to specify information such as video width and height; whether we want it to autoplay and loop, or to show the browser's default video controls, etc.

Browsers don't all support the same video formats; you can provide multiple sources inside nested <source> elements, and the browser will use the first one it understands.

  • If you don't specify the controls attribute, the video won't include the browser's default controls; you can create your own custom controls using JavaScript and the HTMLMediaElement API.
  • There are many events for the video element.
  • You can use the object-position property to adjust the positioning of the video within the element's frame, and the object-fit property to control how the video's size is adjusted to fit within the frame.
  • To show the subtitles/captions along with your video, you can use some JavaScript along with the <track> element and the WebVTT format.
  • You can play audio files using a <video> element. This can be useful, if, for example, you need to perform audio with a WebVTT transcript, since the audio element doesn't allow captions using WebVTT,
  • To test the fallback content on browsers that support the element, you can replace <video> with a non-existing element like <notavideo>.

The <video> element is a replaced element - its display value is inline by default - but its default width and height in the viewport is defined by the video being embedded. There are no special considerations for styling <video>; a common strategy is to give it a display value of block to make it easier to position, size, etc., and then provide styling and layout information as required.


Comments

You have to be logged in to add a comment

User Comments

Insert Math Markup

ESC
About Inserting Math Content
Display Style:

Embed News Content

ESC
About Embedding News Content

Embed Youtube Video

ESC
Embedding Youtube Videos

Embed TikTok Video

ESC
Embedding TikTok Videos

Embed X Post

ESC
Embedding X Posts

Embed Instagram Post

ESC
Embedding Instagram Posts

Insert Details Element

ESC

Example Output:

Summary Title
You will be able to insert content here after confirming the title of the <details> element.

Insert Table

ESC
Customization
Align:
Preview:

Insert Horizontal Rule

#000000

Preview:


View Content At Different Sizes

ESC

Edit Style of Block Nodes

ESC

Edit the background color, default text color, margin, padding, and border of block nodes. Editable block nodes include paragraphs, headers, and lists.

#ffffff
#000000

Edit Selected Cells

Change the background color, vertical align, and borders of the cells in the current selection.

#ffffff
Vertical Align:
Border
#000000
Border Style:

Edit Table

ESC
Customization:
Align:

Upload Lexical State

ESC

Upload a .lexical file. If the file type matches the type of the current editor, then a preview will be shown below the file input.

Upload 3D Object

ESC

Upload Jupyter Notebook

ESC

Upload a Jupyter notebook and embed the resulting HTML in the text editor.

Insert Custom HTML

ESC

Edit Image Background Color

ESC
#ffffff

Insert Columns Layout

ESC
Column Type:

Select Code Language

ESC
Select Coding Language

Insert Chart

ESC

Use the search box below

Upload Previous Version of Article State

ESC