HTML Audio



<audio>

The element <audio> is used to add or play an audio file on a web page

Example:

Syntax:
<audio controls>
<source src="meowing.mp3" type="audio/mpeg" >
Audio is not supported in your browser
</audio>

Output:

Explanation:

controls attribute - this adds controls for the audio such as play, pause and volume modification

source element - this element can have multiple audio files within it. In the case that the first audio file is not available, it will resort to the next alternative audio file

audio element - text inside the audio tags will only appear if the used browser does not support the <audio> element


Additional Audio Attributes

autoplay - to automatically play the audio once the page has loaded

muted - makes the audio muted initially

HTML Logo