How to create a link to play a sound file in HTML

Updated: 05/21/2018 by Computer Hope
sound file

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.


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

Example code

<a href="">Play sound file</a>


Play sound file

<audio> tag

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.

Example code

<audio controls>
<source src="" />


<embed> tag

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="" align="baseline" border="0" width="145" height="60" autostart="false" loop="true">

Using the embed tag method requires that the user has a browser with a plugin, such as QuickTime. For example, the example above requires a plugin that supports MIDI files.

Additional information