Computer >> Computer tutorials >  >> Programming >> HTML

Create a media resources for media elements, defined inside video or audio elements in HTML5.


The HTML <source> tag is used for defining multimedia resources for <audio> and <video> elements. The browser can make a choice from the source based on media type and codec support.

Example

You can try to run the following code to create a media resources for media elements, defined inside video or audio elements in HTML5 −

<!Doctype html>
<html>
   <head>
      <title>HTML source Tag</title>
   </head>
   <body>
      <audio controls>
         <source src = "yourfile.mp3">
         <p>The browser doesnot support the file</p>
      </audio>
   </body>
</html>

The HTML <source> tag also supports the following additional attributes −

Attribute
Value
Description
media Create a media resources for media elements, defined inside video or audio elements in HTML5.
media_query
defines the type of media resource
src Create a media resources for media elements, defined inside video or audio elements in HTML5.
URL
URL of the media file
type  Create a media resources for media elements, defined inside video or audio elements in HTML5.
media_type
media type of media resource