html tutorial - Source <source>-tag in HTML - html5 - html code - html form
Learn html - html tutorial - source tag in html - html examples - html programs
- <source> tag used to defines the media resource for <audio> and <video> tag.
- <source> tag allows multiple alternate resource files for the media elements, the browser may choose the files depends upon the media type and codec support.
- <source> tag supports Global Attributes and Event Attributes.
Syntax for <source> tag:
Differences between HTML 4.01 and HTML5:
HTML 4.01
- HTML4 does not support <source> tag.
HTML5
- HTML5 supports <source> tag.
Sample Coding for <source> tag:
Code Explanation for <source> tag:
- <audio> tag used to define the media element.
- <source> tag used to define the resource of the media element.
- “src” attribute is used to set the source file location for the media element reference.
- There are two audio file source is mentioned, welcome.mp3, welcome.wav.
Output of <audio> tag:
- Here the audio file is displayed in the output with volume adjustment.
Attribute List:
Attribute | Value | HTML4 | HTML5 | Description |
---|---|---|---|---|
media | media_query | No | Yes | Specifies the type of media resource |
src | URL | No | Yes | Specifies the URL of the media file |
type | media_type | No | Yes | Specifies the media type of the media resource |
Browser Support for <source> tag:
Browser | Mp3 | wav | ogg |
---|---|---|---|
Yes | Yes | No | |
Yes | No | Yes | |
Yes | Yes | Yes | |
Yes | Yes | No | |
Yes | Yes | Yes |