Embedding Audio/Sound in background

Embedding Audio/Sound in background

How to add or embed audio as background in html files?


It will be nice to hear a background music while working with html files. And now its simple to include an audio file into HTML page. There are different syntax for different browsers. For example, internet explorer support the BGSOUND and netstcape support an embed tag for embedding musics.
Free music downloads are available at various sites. Those websites will give us a trail to download and hear the music. We can just use those files in our html pages. In such cases, the embed tag is used much.
In Internet Explorer the audio can be included using tag. bgsound tag works only in IE and not in any other browsers.
Example :

The audio can be included using tag for netscape like browsers.
Example :

This will include backgound music into your webpage. If you want to display the controls in the browser, you can set the hidden attribute to false. Here in the above example we have used Loop=-1 which will play the file again and again. If you want to play it only once just set the loop to false.

  • SRC: This attribute takes the audio to the source URL.
  • WIDTH and HEIGHT: It manages the size of the plug-ins in html page.
  • AUTOSTART: Its value can be either TRUE or false
    TRUE: It will play the sound when the page loads.
    FALSE: It will wait for the user to click on the play button.
  • LOOP: The default value is FALSE which plays the file only once. Setting this to TRUE will play the sound continuously.

Example :

When you use the META tag element, the browser displays an dialog box which asks for what should firefox do with this file?. You can choose the player of your wish to play the song. For example, if you are opening with Windows Media Player then, the browser will take you to the windows Media player to play the song.
Using the Object Tag:
Apart from the non standard Embed tag, we can also use the tag for embedding medias into our web pages. But, it is not still effective for cross-browser functions.
You can specify some parameters related to the document with the param tag. IE sometimes needs a src parameter to understand the location
Example :

Hear the sound : music

Type attribute specifies the application/media player type you are using.
Use the following type for your media player,

Windows Media Player : type=”application/x-mplayer2″.
Quicktime: type=”video/quicktime”.
RealPlayer: type=”audio/x-pn-realaudio-plugin”.


The parameters autoplay is understandable by QuickTime, autoStart by Windows media Player and Real Audio.

Leave a Reply

Your email address will not be published. Required fields are marked *