Background sounds are simply sounds that are downloaded and played automatically when the visitor loads a Web page in his browser.

Background sounds can be embedded into a Web page by using the <BGSOUND src=soundURL loop=value> tag.

The src attribute locates the sound file while the loop attribute tells the Web browser how many times to repeat playing the sound file. To play the sound file repeatedly, simply assign infinite to loop.

Click here to review the page that loads and plays a MIDI sound file as background music in the Web browser.

<HTML>
<HEAD>
<TITLE>Enter the Page Title Here</TITLE>
</HEAD>
<BODY>
<BGSOUND src="download/music.mid" loop=infinite>
This page loads and plays a MIDI file as background music repeatedly.
</BODY>
</HTML>

Note that both MIDI (i.e., .mid) or Wave (i.e., .wav) files can be used for background music. However, it is always better to use a MIDI file for background sound because it is much smaller in file size.

It is also important to note that Netscape Navigator does not support the BGSOUND tag.

 

Another way to embed background sound into a Web page is to use the <EMBED> tag.

The autostart attribute ensures that the sound will be played immediately once the page is loaded. Assigning true to the loop attribute instructs the browser to play the sound infinitely. The hidden attribute determines whether the player will show up on the Web page or not.

Click here to review the page that loads and plays a MIDI sound file as background music in the Web browser.

<HTML>
<HEAD>
<TITLE>Enter the Page Title Here</TITLE>
</HEAD>
<BODY>
<EMBED src="download/music.mid" autostart=true loop=true hidden=true>
This page loads and plays a MIDI file as background music repeatedly.
</BODY>
</HTML>