Represents an interface for adding audio content to the page.
HTML supports the following audio formats:
<audio controls><!-- Source tags with different audio formats go here --></audio>
<audio> element may contain one or more
<source> elements with different audio formats. The browser will run the format most suitable for the browser.
<audio> tag may include
<source> tags and fallback text. It may also use attributes to convey intention, such as the ones listed below:
autoplayautomatically plays the audio.
controlshas an overlay to allow the user to control the audio.
loopspecifies that when the audio ends, it will begin again.
srcto the URL for the audio to be shown to the user.
<audio controls><source src="audioFile_name.ogg" type="audio/ogg" /><source src="audioFile_name.mp3" type="audio/mpeg" /><h3>Fallback text if audio will not play</h3></audio>
In the example above, the
<audio> element contains the
controls attribute to display user controls for the audio content such as a play and pause button. In addition, there are two
<source> tags with different audio formats. If the browser doesn’t support the
.ogg file format, it will use the
.mp3 file. Lastly, the text that follows the
<source> tags will display if the
<audio> tag is not supported by the browser.