Which attribute is used to add video control in html?

The HTML element is used to show a video on a web page.

The HTML Element

To show a video in HTML, use the element:

Example


 
 
Your browser does not support the video tag.

Try it Yourself »

How it Works

The controls attribute adds video controls, like play, pause, and volume.

It is a good idea to always include width and height attributes. If height and width are not set, the page might flicker while the video loads.

The element allows you to specify alternative video files which the browser may choose from. The browser will use the first recognized format.

The text between the and tags will only be displayed in browsers that do not support the element.

HTML Autoplay

To start a video automatically, use the autoplay attribute:

Example


 
 
Your browser does not support the video tag.

Try it Yourself »

Note: Chromium browsers do not allow autoplay in most cases. However, muted autoplay is always allowed.

Add muted after autoplay to let your video start playing automatically [but muted]:

Example


 
 
Your browser does not support the video tag.

Try it Yourself »

Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Element
4.0 9.0 3.5 4.0 10.5

HTML Video Formats

There are three supported video formats: MP4, WebM, and Ogg. The browser support for the different formats is:

BrowserMP4WebMOgg
Edge YES YES YES
Chrome YES YES YES
Firefox YES YES YES
Safari YES YES NO
Opera YES YES YES

HTML Video - Media Types

File FormatMedia Type
MP4 video/mp4
WebM video/webm
Ogg video/ogg

HTML Video - Methods, Properties, and Events

The HTML DOM defines methods, properties, and events for the element.

This allows you to load, play, and pause videos, as well as setting duration and volume.

There are also DOM events that can notify you when a video begins to play, is paused, etc.

For a full DOM reference, go to our HTML Audio/Video DOM Reference.

HTML Video Tags

TagDescription
Defines a video or movie
Defines multiple media resources for media elements, such as and
Defines text tracks in media players



Example

Play a video:


 
 
  Your browser does not support the video tag.

Try it Yourself »

Definition and Usage

The tag is used to embed video content in a document, such as a movie clip or other video streams.

The tag contains one or more tags with different video sources. The browser will choose the first source it supports.

The text between the and tags will only be displayed in browsers that do not support the element.

There are three supported video formats in HTML: MP4, WebM, and OGG.

BrowserMP4WebMOgg
Edge YES YES YES
Chrome YES YES YES
Firefox YES YES YES
Safari YES YES NO
Opera YES YES YES

Tips and Notes

Tip: For audio files, look at the tag.

Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Element
4.0 9.0 3.5 3.1 11.5

Optional Attributes

AttributeValueDescription
autoplay autoplay Specifies that the video will start playing as soon as it is ready
controls controls Specifies that video controls should be displayed [such as a play/pause button etc].
height pixels Sets the height of the video player
loop loop Specifies that the video will start over again, every time it is finished
muted muted Specifies that the audio output of the video should be muted
poster URL Specifies an image to be shown while the video is downloading, or until the user hits the play button
preload auto
metadata
none
Specifies if and how the author thinks the video should be loaded when the page loads
src URL Specifies the URL of the video file
width pixels Sets the width of the video player

Global Attributes

The tag also supports the Global Attributes in HTML.

Event Attributes

The tag also supports the Event Attributes in HTML.

Related Pages

HTML DOM reference: HTML Audio/Video DOM Reference

Default CSS Settings

None.



Which attribute is used to add video file in HTML?

HTML allows playing video in the web browser by using tag. To embed the video in the webpage, we use src element for mentioning the file address and width and height attributes are used to define its size.

How do I show the controls of a video in HTML?

The HTML controls attribute is used to display video controls in HTML5. It is the Boolean value..
Pause..
Volume..
Full-screen Mode..
Seeking..
Captions/Subtitles[if available].
Track[if available].

What is the attribute to enable controls on video >

Chủ Đề