Open In App

HTML <source> type Attribute

Last Updated : 07 Jun, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

The HTML <source> type attribute is used to specify the MIME type of the media resource.
Syntax: 
 

<source type="media_type">


Attribute Values: It contains single value MIME_type which specifies the MIME_type of the media resource. Few MIME types are video/ogg, videomp4, audio/ogg etc.
Example 1: This example illustrates the use of <source> type attribute with the audio file. 
 

html
<!DOCTYPE html> 
<html> 

<head> 
    <title>
        HTML source type Attribute
    </title>
</head> 

<body style="text-align:center;"> 
    
    <h1 style="color:green;">
        GeeksforGeeks
    </h1> 
    
    <h3>HTML Source type Attribute</h3> 
    
    <audio controls> 
        <source src=
"https://write.geeksforgeeks.org/wp-content/uploads/11.wav"
            type="audio/mpeg"> 
    </audio> 
</body> 

</html>                                            

Output: 
 


Example 2: This example illustrates the <source > type attribute with the video file. 
 

html
<!DOCTYPE html> 
<html> 

<head> 
    <title>
        HTML source type Attribute
    </title>
</head> 

<body style="text-align:center;"> 
    
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>  
    
    <video width="420" height="240" controls>
        <source src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190614120700/20190614_112020.mp4"
            type="video/mp4"> 
    </video> 
</body> 

</html>                                                           

Output: 
 

Supported browsers: 

  • Google Chrome 
  • Edge 12 and above
  • Internet Explorer 9.0 and above
  • Mozilla Firefox 3.5 and above
  • Safari 
  • Opera 


 


Next Article

Similar Reads