How to create a link to play a sound file in HTML
Linking to a sound file using a href allows a browser to open and play an audio file if the viewer of your web page has properly configured their Internet browser. You can also use the <embed> tag or the newer <audio> tag to insert a sound file directly into a web page.
Tip: When it comes to audio files, we recommend using the .MP3 file format because it is widely accepted, utilized by all browsers and operating systems.
<a href> tag
<a href="https://www.computerhope.com/jargon/m/example.mp3">Play sound file</a>
For all modern browsers, you can utilize the <audio> tag to have a usable media player as part of the web page to allow the visitor to play, stop, pause, and even download an audio file.
<audio controls> <source src="https://www.computerhope.com/jargon/m/example.mp3" /> </audio>
An older method of including audio files is to use the <embed> tag. While this method certainly works, it is less efficient than those which were mentioned above. As such, we recommend using one of the solutions demonstrated above.
<embed src="https://www.computerhope.com/clouds.mid" align="baseline" border="0" width="145" height="60" autostart="false" loop="true">
- How to insert a movie or video into an HTML document.
- How to add pictures to an HTML website.
- See our sound definition for further information and related links.
- HTML help and support.