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

Updated: 07/13/2023 by Computer Hope
sound file

With HTML (hypertext markup language), linking 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. Alternatively, use the <embed> tag or the newer <audio> tag to insert a sound file directly in a web page.


With audio files, we recommend using the .MP3 file format because of its wide acceptance on the Internet, and is utilized by all browsers and operating systems.

<a href> tag

Example code

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


Play sound file

<audio> tag

The <audio> tag can create a media player as part of the web page. It allows the visitor to play, stop, pause, or download an audio file. The <audio> element is compatible with all modern web browsers.

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">