The Developer Brains


  HTML Audio

Web Designing | Web Development


SEE MORE














</HTML Audio tag>





Audio tag in HTML

HTML5 provides a new standard for embedding an audio/video file on a web page. You can embed an audio file to a page using the <audio> element:

				
      
      <audio controls>
          <source src="audio.mp3" type="audio/mp3">
          Your browser does not support the audio tag.
          // this text display when your do't support audio tag
      </audio>

       
            
				
Try it Yourself

Example



SEE MORE




















</HTML Audio>


Attribute/tag Details
<source> Defines resources of the audio or video files
controls Displays controls
autoplay Automatically start playing the media when page load
loop Plays the media in a repeated cycle
muted Plays the media without sound

Using <audio> element to display audio/video content

Use the HTML or <audio> element to embed video/audio content in a document. The video/audio element contains one or more video/audio sources. To specify a source, use either the src attribute or the <source> element; the browser will choose the most suitable one.

Using src attribute to display audio/video content


				
<audio src="audio.mp3" controls>
 Sorry, your browser doesn't support embedded audios,
 but don't worry, you can 
 <a href="audio.mp3">download it</a>
 and watch it with your favorite audio player!
</audio>
      
            
				
Try it Yourself

Using <source> tag to display audio/video content

The <source> tag allows you to specify multiple audio format for the browser to choose from. The browser uses the first recognized format.


				
<audio width="480" controls>
 <source src="audio.mp3" type="audio/mp3">
 <source src="audio.ogg" type="audio/ogg">
 <source src="audio.wav" type="audio/wav">
 Your browser doesn't support HTML5 audio tag.
</audio>
            
				
Try it Yourself

HTML <audio> controls attribute

The Controls attribute to display audio controls, like play, pause, and volume.


				
<audio width="450"  controls>
  <source src="audio.mp3" type="audio/mp3">
    Your browser does not support the audio tag.
</audio>
            
				
Try it Yourself

HTML <audio> autoplay attribute

A Boolean attribute; if specified, the audio automatically begins to play back as soon as it can do so without stopping to finish loading the data. Automatically start playing the media when page load.
An audio file that will automatically start playing:


				
<audio width="450"  autoplay>
  <source src="audio.mp3" type="audio/mp3">
    Your browser does not support the audio tag.
</audio>
            
				
Try it Yourself


HTML <audio> loop attribute

A Boolean attribute; if specified, the browser will automatically seek back to the start upon reaching the end of the media.
Plays the media in a repeated cycle(loop)


				
<audio width="450" loop>
  <source src="audio.mp3" type="audio/mp3">
    Your browser does not support the audio tag.
</audio>
            
				
Try it Yourself

HTML <audio> muted attribute

A Boolean attribute that indicates whether the audio will be initially silenced. Its default value is false.
Plays the media without sound


				
<audio width="450" muted>
  <source src="audio.mp3" type="audio/mp3">
    Your browser does not support the audio tag.
</audio>
            
				
Try it Yourself













</HTML> Quiz Question>


Which attribute play audio automatically?



Check Now



HTML5 QUIZ







Previous: HTML5 Media and Elements
Next: HTML5 Quiz


Previous

      

Next Page













  Share TDB SCHOOL  

Share this E-Learning Website on social media platforms with your friends and followers