This page is describing the attributes assigned only to media group of HTML5 elements.

Attributes and related elements:

src attribute:

<video><audio><source><track><embed />

type attribute:

<video><audio><source><embed />

srclang attribute:

<track>

autoplay attribute:

<video><audio>

controls attribute:

<video><audio>

muted attribute:

<video><audio>

loop attribute:

<video><audio>

preload (metadataautonone) attribute:

<video><audio>

poster attribute:

<video>

media attribute:

<source>

kind (captionschapterssubtitlesdescriptionsmetadata) attribute:

<track>

label attribute:

<track>

default attribute:

<track>

width and height attributes:

<video><embed />

Attribute characteristics and purpose:

src attribute:

  • <video>: provides the path of the video file in form of URL
  • <audio>: provides the path of the audio file in form of URL
  • <source>: provides the path of the media (video or audio) file in form of URL
  • <track>: provides the path of the text track data file in form of URL; the file has to be in a specific format, such as a WebSRT or WebVTT; this attribute is required
  • <embed />: provides the path of the external file to be used; it has to be in a form of URL

type attribute:

  • <video>defines MIME-type of the media source
  • <audio>:  defines MIME-type of the media source
  • <source>: defines a valid MIME-type of the media source (.mp3, .ogg. wav...); browser determines whether to play it or not
  • <embed />: specifies the media type that of the embedded object

srclang attribute:

  • <track>: indicates the language of the text track data

autoplay attribute:

  • <video>: tells a browser whether to start playing the video as soon as it loads or not; value is Boolean
  • <audio>: tells a browser whether to start playing the audio as soon as it loads or not; value is Boolean

controls attribute:

  • <video>: if enabled, provides a browser default video controls; a Boolean value
  • <audio>: if enabled, provides a browser default audio controls; a Boolean value

muted attribute:

  • <video>: used to mute an automatic play during loading or other states; not well supported by browsers
  • <audio>: used to mute an automatic play during loading or other states; not well supported by browsers

loop attribute:

  • <video>: makes video play in an infinite loop (repentance); a Boolean value.
  • <audio>: makes audio play in an infinite loop (repentance); a Boolean value

preload (metadataautonone) attribute:

  • <video>: suggests a browser how to preload a video; ultimately it depends on browser how to do it
  • <audio>: suggests a browser how to preload a audio; ultimately it depends on browser how to do it

poster attribute: 

  • <video>: if there is no video data available, this attribute will replace a first frame of the video (if available) with an image of your choice; a value must be a URL source of the image.

media attribute:

  • <source>: specifies resources to be used for the intended media type; typical resource data may be a device type (screen, braille...), width and height, or a certain ratio

kind (captionschapterssubtitlesdescriptionsmetadata) attribute:

  • <track>: specifies what kind of data the track provides for the specific media element

label attribute:

  • <track>: defines a title for the track; this title will be readable by users and will carry unique across track elements

default attribute:

  • <track>: if selected it will tell the browser that the track must be enabled (unless user preferences indicate otherwise)

width and height attributes:

  • <video>: define width / height of the video element in pixels
  • <embed />: define the width / height of the embedded object in pixels

Examples

Example with video, source and track elements attributes:

Example with audio element attributes:

 

›› go to examples ››