You are here: > >

Creating a link to play a sound file in HTML

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

<A HREF> tag

<A HREF="">Click here to play sound</a>

<embed> tag

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

Note: Using the embed 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.

<audio> tag

<audio src="example.midi" preload="auto" autoplay="autoplay"></audio>


Using the A HREF tag creates a link to the sound file on the web page, like the example shown below.

Click here to play sound

Using the embed tag embeds the sound file in the web page, as shown in the example below.

Additional information

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