Open In App

HTML <source> type Attribute

Last Updated : 07 Jun, 2023
Improve
Improve
Like Article
Like
Save
Share
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=
            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=
            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 

 



Similar Reads

HTML DOM Source type Property
The Source type Property in HTML DOM is used to set or return the value of the type attribute in a &lt;source&gt; element. The type attribute is used to specify the MIME type of the media resource. Syntax: It returns the Source type property. sourceObject.typeIt is used to set the Source type property.sourceObject.type = MIME_type Property Values:
2 min read
HTML | &lt;source&gt; src Attribute
The HTML &lt;source&gt; src attribute is used to specify the URL of the media resource. The source element is used as a child element of the &lt;audio&gt; and &lt;video&gt; element. Syntax: &lt;source src="URL"&gt; Attribute Values: It contains single value URL which specifies the URL of the media resource. There are two types of URL link which are
1 min read
HTML | &lt;source&gt; media Attribute
The HTML source media attribute accepts any valid media query that would normally be defined in a CSS. This attribute can accept several values. Syntax: &lt;source media="media_query"&gt; Possible Operators: Value Description and AND operator not NOT operator , OR operator Devices: Value Description all Suitable for all devices aural Speech synthes
2 min read
HTML | &lt;source&gt; srcset Attribute
The HTML srcset attribute is used to specifies the URL of an image to use in different situations. when &lt;source&gt; is used in &lt;picture&gt; it is requiredSyntax: &lt;source srcset="URL"&gt; Attribute Values URL: It specifies the URL of image Example: C/C++ Code &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta name=&quot;viewport&quot;
1 min read
HTML | &lt;area&gt; type Attribute
The &lt;area&gt; type attribute is used to specify the Internet media type of the linked document. It is used only when href attribute is set.Syntax: &lt;area type="media_type"&gt; Note: This attribute is not supported in HTML5. Attribute Values: It contains single value media_type which is used to specify the Internet media type of the embedded fi
1 min read
HTML | &lt;button&gt; type Attribute
The &lt;button&gt; type attribute is used to specify the type of button. It specifies the type attribute of &lt;button&gt; element. The default types of &lt;button&gt; element can vary from browser to browser. Syntax: &lt;button type="button|submit|reset"&gt; Attribute Values: submit: It defines a submit button. It has a default value for all brows
1 min read
HTML | &lt;script&gt; type Attribute
The HTML &lt;script&gt; type Attribute is used to specify the MIME type of script and identify the content of the Tag. It has a Default value which is “text/javascript”. Syntax: &lt;script type="media_type"&gt; Attribute Values: It contains a single value i.e media_type which specifies the MIME type of script.Common "media_type" values are: text/ja
1 min read
HTML | &lt;object&gt; type Attribute
The HTML &lt;object&gt; type Attribute is used to specify the Internet type of MIME type of the Object. Syntax: &lt;object type="media_type"&gt; Attribute Values media_type It is used to specify the Internet media type of the embedded file. Example: C/C++ Code &amp;lt;!DOCTYPE html&amp;gt; &amp;lt;html&amp;gt; &amp;lt;body&amp;gt; &amp;lt;center
1 min read
HTML | &lt;li&gt; type Attribute
The &lt;li&gt; type attribute in HTML is used to specify the type of a list items. This attribute also defines the style of the bullet point of the list items. Syntax: &lt;li type="1|a|A|i|I|disc|circle|square"&gt; Attribute Values: For ordered list items: 1: It is the default value. It is used to specify the numerical ordered list.a: It arranged t
2 min read
HTML | &lt;embed&gt; type Attribute
The HTML embed type Attribute contains the media_type content. It is used to specify the media type of the embedded content. Syntax: &lt;embed type="media_type"&gt; Attribute Values: media_type: It contains the media_type content. It is used to specify the media type of the embedded content. Example: C/C++ Code &amp;lt;!DOCTYPE html&amp;gt; &amp;lt
1 min read