FREE HTML CODE
Search HTML Code

HTML Music Codes

How to embed an audio file

You can embed a music file into your page using the following HTML code:


<embed name="lostmojo"
src="/web_design/lostmojo.wav"
width="300"
height="90"
loop="false"
autostart="false" />


This code will present a music console with the appropriate controls like this:
(If you don't see any music controls and don't hear any music, you may need to download a plugin for your browser.)


Need to create a music playlist?

You can make your music player loop through more than one song using a music playlist.


How to preload a sound file

You can preload music files so that the music starts immediately after the user has clicked on the link. You can preload using the following technique:



<embed name="lostmojo"
src="/web_design/lostmojo.wav"
loop="false"
autostart="false"
hidden="true"
mastersound />

This embeds the sound, but the 'autostart' feature is off (you don't want to annoy the user now, do you?) and the 'hidden' feature is true, so the user doesn't see a console upon entering your webpage.

How to link to a music file

You can also link to a music file using the <a href= tag. All you need to do is write something like this:


Listen to a sample of <a href="/web_design/lostmojo.wav">Lost Mojo</a>
| More