If you find this helpful, please click the Google Button to the left, if it is white, to make it turn blue or red. Thank you! (It also helps find this page again more easily.) |
The <source> Tag in HTML 5
The source
tag identifies one possible source of the embedded audio or video media indicated by its parent tag. The parent tags under which <source>
tags can be coded are:
More than one source
tag can be included within an <audio>
tag or <video>
tag to allow different browsers to choose among multiple source formats. The attributes of the source
tag supply the location of the content to be included and additional information needed to decode the content.
<source/> Tag Syntax
Rules for coding HTML source/
elements
<source .../>
<source/> Content Model
Contents of the source element
Content: Empty. All properties are coded using attributes.
Since the <source/>
tag is a void element, it is not allowed to have any content, even HTML comments and therefore should always be coded as a self-closing standalone tag, ending with the delimiter string />
rather than just >
(<source .../>
).
<source/> Tag Attributes
Attributes of the <source/> tag
global attributes | In addition to the personal attributes of the <source> tag below, any of the common HTML attributes can also be coded. |
codecs |
The codecs attribute indicates which codecs should be used for decoding the content referenced by the src attribute. |
src |
a URI reference that resolves to the URL of the media resource Use percent escape codes as explained in the URL-encoding tutorial for any special characters in the URI. If the value of the
If the protocol scheme, username, host name/IP address and port number are omitted the default is the current host - the same server as the one handling the current document. If the path starts with a slash |
type |
The type attribute is the MIME media type of the video content. |
<source/> Tag Examples
Examples of the source
element in HTML 5
Changes in HTML 5 - <source> Tag
What's new in HTML 5
Differences between HTML 5 and earlier versions of HTML
The <source> tag did not exist in older versions of HTML.
The 2000-2010 Recommendations from the W3C HTML Working Group defined the HTML namespace for the names of all HTML element types, which now includes the source element name. In older (pre-2000) versions of HTML, element type names were not associated with a namespace.