How to Add Background Music to Your Web Page
In the old days PCs weren't very interesting because the only sound they made was the
wurring of the fan. Eventually music and multimedia came to the PC, but because of the low
bandwidth of dial-up, the Internet was still dead quiet.
Today most Web users have a broad-band connection, so you can add music and even video to
your webpage without slowing down the users browser much. In this article, I show you how,
with just a few lines of code, you can give your webpage an extra touch of class by adding
But first let me advise you to NOT add background music to your webpage. Why not?
Because many Web users have intentionally disabled sound on their computers. Almost everybody
likes music - their own music, not your music. Many people are playing their own favorite
music while surfing the web. Personally my favorite music is the rarest sound on the
planet - PEACE and QUIET.
That being said, and assuming you're intent on adding music to your webpage, first I'll
show you two ways you should NOT use to add music, and then the correct way to add music
to your webpage. The first way to NOT add music to your webpage is to use the
<bgsound> tag, an example of this is shown below.
<bgsound src="SugarplumFairy.mp3" volume="-1000" loop="infinite" />
Below are some of the attributes you can use with the <bgsound> tag.
balance - a number between -10,000 and +10,000 that specifies how the volume will be
divided between speakers.
loop - a number that specifies how many times a sound is to be played, or for continuous
looping, the keyword "infinite".
src - the URL of the sound file to be played.
volume - a number between -10,000 and 0 that specifies the loudness.
You can place the code for the <bgsound> tag anywhere on your webpage. Why not
use the <bgsound> tag? Because the it's not part of any W3C standard. It's an Internet
Explorer proprietary tag that will work with any version of Internet Explorer (except version 1).
The <bgsound> tag is not part of any W3C standard, but it's easy to use and it
continues to work, even with Internet Explorer version 7.
The second way to NOT add music to your webpage is to use the <embed> tag, an
example of this is shown below.
<embed src="SugarplumFairy.mp3" autostart="true" height="45" width="200" loop="true" />