Last Updated on April 26, 2023 by Roshan Parihar
HTML source tag is used to show media resources in web pages. The audio tag and video tag are the media resources which we can show inside a web page.
1 |
<source src="url of audio source file" type="mention the type of file video or audio/wav or mp3 or ogg or mp4"> |
This is the example to show audio using source tag.
1 2 3 4 |
<audio controls> <source src="../media/peacock.wav" type="audio/wav" autoplay="true"> Your Browser does not support the audio element </audio> |
Output
You must also read
- HTML audio tag to display audio source in HTML.
This is the example to show video using source tag.
1 2 3 4 |
<video width="320" height="240" controls> <source src="../media/birdreaction.mp4" type="video/mp4" autoplay="true"> Your Browser does not support the video element </video> |
Output
You must also read
- HTML video tag to display video source in HTML.
List of allowed HTML Audio/Video Formats
Sr. No. | HTML Audio/Video availble formats for source tag | Description |
---|---|---|
1 | mp3 | Used to include mp3 extension files. |
2 | ogg | Used to include ogg extension files. |
3 | wav | Used to include wav extension files. |
4 | mp4 | Used to include mp4 extension files. |
5 | webm | Used to include webm extension files. |
List of HTML source tag attributes
Sr. No. | attribute options | Description |
---|---|---|
1 | src | Used to include location of media resources. The value for this attribute is the url of the media video/audio files. |
2 | type | Used to specify the type of the media files whether it is video or audio extension files. video/mp4, audio/mp3 etc are the values for this attribute. |
3 | autoplay | Used to specify the boolean value to start and play the sources. The value for this are true and false. |
Resources and References
1. W3C Specification.
2. HTML living standard
3. W3C project using Github