The source tag
The source
tag inserts an audio or video file for the audio
and video
tags. This tag is needed to specify paths to audio or video recording files in different formats (since browsers support different audio formats, for example mp3
or wav
). To do this, the audio
or video
tag must contain several source
tags with files in different formats. The browser will go through these tags in order until it finds a file in a format that it can play.
The closing tag is optional.
Attributes
Attribute | Description |
---|---|
src |
Specifies the path to an audio or video file.
Required attribute. |
media |
Specifies the device for which the audio or video file will be played. |
type |
File type and codec names to open it. Example: video/ogg; codecs="theora, vorbis .
|
Example .
Let's add the tag source
for the tag audio
:
<audio controls>
<source src="track.mp3">
Your browser does not support HTML5 audio.
</audio>
Example .
Let's add the source
tag to the video
tag:
<video>
<source src="moovie.mp4" controls>
Your browser does not support HTML5 video.
</video>