1. Computing

Discuss in my forum

How To Add Background Music to Your Web Page

By , About.com Guide

Adding background music to a Web page can be very challenging, especially if you want to stay compliant with XHTML. In fact, the compliant method works in Netscape and Mozilla, but not in Internet Explorer. This document will teach you how to use both valid and invalid methods to add background sound.

Difficulty: Hard
Time Required: 10 minutes

Here's How:

  1. Valid Method First make sure that your document has an XHTML doctype listed as the first tag on the page (Note: The » symbol indicates a line wrap, delete both the character and the carriage return from your code.):
    xhtml1-transitional.dtd">
  2. Find a location on your page where you would want controls to appear.
  3. Add in an object tag:
    
    
    Change "soundfile.mid" to the midi you want to play. If you change it to a wav or other audio file, change the codetype as well.
  4. Save your page and upload both the page and the sound file.
  5. Invalid IE Method For this method, you don't need a valid doctype.
  6. Inside the element, place a bgsound tag:
    Change "soundfile.mid" to the sound file you want to play.
  7. Save your page and upload both the page and the sound file.

Tips:

  1. I strongly recommend you consider avoiding automatic playing sound on your Web pages. It can be very annoying and drive customers away.
  2. If you must have background sound, use the valid XHTML, unless you know that the customers you want to reach use Internet Explorer.

©2013 About.com. All rights reserved.