HTML Audio

HTML Tutorial

HTML Forms

HTML Graphics

HTML Media

HTML API

HTML Audio

The HTML <audio> element plays an audio file on a web page.

The HTML <audio> Element

Using the <audio> element plays an audio file in HTML:

Example

				
					<audio controls>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

				
			

Output:

HTML Audio – How It Works

  • The controls attribute is used of adding the audio controls, like play, pause, and volume.
  • The <source> element specifies alternative audio files from which the browser may choose. The browser recognizes the first format used.

HTML <audio> Autoplay

Using the autoplay attribute, starts an audi file automatically:

Example

				
					<audio controls autoplay>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element

				
			

HTML Audio – Methods, Properties, and Events

  • The HTML DOM specifies methods, properties, and events for the <audio> element.
  • It enables you to load, play, and pause audios, as well as set duration and volume.

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420