Name
source — HTML5
Synopsis
HTML: <source>; XHTML: <source/> or <source />
Used within audio
and
video
elements, source
allows authors to specify multiple
versions of a media file. When source is used, the src
attribute should be omitted from the
audio
and video
elements. User agents will go down the
list of source
elements until they
find a format they are able to play.
Notes
HTML5 only.
Start/End Tags
This is an empty element. It must be closed with a trailing slash in XHTML5.
Attributes
HTML5 Global Attributes
media="all|aural|braille|handheld|print|projection|screen|tty|tv"
Specifies the target display media for the audio or video file.
src="
URL
"
Specifies the location of the audio or video file.
type="
MIME type
"
Indicates the file type of the media file and may also include the
codecs=
MIME parameter indicating the codec used to encode the media.
Example
<video> <source src="media/vacation.ogv" type="video/ogg; codecs='theora, vorbis'"> <source src="media/vacation.mp4" type="video/mp4"> Your browser doesn't support the <code>video</code> element. </video>
Get HTML & XHTML Pocket Reference, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.