HTML and CSS Reference
In-Depth Information
<source src="video/Gamera-mobi.ogv"
media="screen and (max-device-width: 600px)"
type='video/ogg;codecs="theora,vorbis"'>
</video>
Required Attributes
src
: Specifies the URL where the media file or stream resides on a web server.
Optional Attributes
type
: The media source's media type (also called a MIME type). This may optionally include the
specific codec(s) used to encode the media.
media
: The output media or devices for which the embedded media is optimized. This attribute's
value is a comma-separated list of valid media queries, as taken from the CSS specification
(
w3.org/TR/css3-mediaqueries
). The default value is “
all
” if the attribute is empty or omitted.
track
A
track
element specifies the address of an external
timed text track
for a media element, either
audio
or
video
. Such a text track can provide accessible captions for the hearing impaired, or subtitles for other
languages, additional text descriptions, annotations, or metadata about the media. This is a recent addition
to HTML5 and browsers don't support text tracks yet.
The
track
element is a void element with no end tag, and it can only appear as a child of an
audio
or
video
element. Within an
audio
or
video
element,
track
elements should come
after
all
source
elements and
before
any other flow elements (such as an
object
,
embed
, or any other fallback content):
<video controls>
<source src="video/mechanical-monsters.ogv" type="video/ogg">
<source src="video/mechanical-monsters.mp4" type="video/mp4">
<track kind="subtitles" src="video/tracks/mechmon-en.vtt"
srclang="en" label="English subtitles" default>
<track kind="subtitles" src="video/tracks/mechmon-ja.vtt"
srclang="ja" label="Japanese subtitles">
<track kind="captions" src="video/tracks/mechmon-cap.vtt"
srclang="en" label="English captions for the hearing impaired">
<p>Download this exciting video clip in
<a href="video/mechanical-monsters.ogv">Ogg Theora</a> or
<a href="video/mechanical-monsters.mp4">MP4</a> format.</p>
</video>
If there are multiple
track
elements present, you can mark one of them as the default text track with the
Boolean
default
attribute; without this attribute the first
track
acts as the default.
Each
track
element requires a
src
attribute supplying the URL of the text track data. Also important is the
kind
attribute, specifying what kind of text track the browser is dealing with. There are only a few different
kinds of tracks: