Member-only story
Everything You Should Know About the Audio Tag in HTML and JavaScript
Include audio in HTML, and play and pause it in JavaScript

The audio
tag allows you to add audio to your web pages. The audio
tag is introduced in HTML5
.
Adding an audio
tag is super easy:
<audio src="/music/meow.mp3"> </audio>
You can also show a message if the browser doesn’t support the audio
tag:
<audio src="/music/meow.mp3"> You're browser is Outdated . Please Update The Browser</audio>
Attributes
Controls
The above code alone doesn’t play the music or show anything. We need to add the controls
attribute to enable play
and pause
of the audio. By default, controls
is false
. You can add enable control of the audio tag by adding either controls
or controls = "true”
.
<audio src="/music/meow.mp3" controls> You're browser is Outdated . Please Update The Browser</audio>
Don’t forget to add controls
; otherwise, nothing will be displayed.