Creating a link to play a sound file in HTML

Updated: 04/26/2017 by Computer Hope

sound fileInserting the sound file in an A HREF tag allows the browser to open and play the 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 into a web page.

Tip: For the type of audio file we recommend using .MP3 because it is widely accepted in all browsers and operating systems.

<a href> tag

<A HREF="../jargon/m/example.mp3">Play sound file</a>


Play sound file

<audio> tag

For all modern browsers you can use 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 the audio file.

<audio controls>
<source src="../jargon/m/example.mp3" />


<embed> tag

An older method of including audio files is using the embed tag to embed a file into the HTML file. Today, instead of using this method we recommend using one of the above solutions.

<embed src="" align="baseline" border="0" width="145" height="60" autostart="false" loop="true">

Note: Using the embed tag method requires that the user has a browser that has a supported plugin, such as QuickTime, that supports the ability to play MIDI files. Most browsers today do not have plugins to support MIDI files. Instead of playing MIDI files, we suggest using MP3 files.

Additional information

  • See our sound definition for further information and related links on this term.