References

Collection of references for web development.

HTML audio tag

Description

The HTML <audio> element is used to embed sound in the document.

Attributes

Attribute Value Description
autoplay boolean Specifies whether the media source should automatically play or not.
buffered TimeRanges Object Determines which time ranges of the media have been buffered.
controls boolean Specifies whether the browser should show controls for the user.
loop boolean If true, the media will continuously start from beginning when it has reached its end.
muted boolean Specifies whether the media should be silenced or not.
played TimeRanges Object Determines the time ranges of the media that have been played.
preload auto
metadata
none
Specifies how the author will think how the media should be loaded.
src URL The URL of the file to embed in the document.
volume From 0.0 (silent) to 1.0 (loudest) Specifies the playback volume, from silent to loudest.

Example

<audio src="https://codeshack.io/web/example.ogg" controls>
	Your browser does not support the audio element.
</audio>

Example #2

<p>Fallback Example</p>
<audio controls>
	<source src="https://codeshack.io/web/example.opus" type="audio/ogg; codecs=opus">
	<source src="https://codeshack.io/web/example.ogg" type="audio/ogg; codecs=vorbis">
	<source src="https://codeshack.io/web/example.mp3" type="audio/mpeg">
</audio>