Skip to: content, navigation

bgsound (HTML element)

Spec
Depr. Empty Version
No Yes N/A
Browser support (more…)
IE5.5+ FF2 SA3 OP9.5
Full None None None

Syntax

<bgsound balance="value for left/right balance" loop="number of times to loop audio" src="URL of audio file" volume="volume of audio file">

Description

The bgsound element is used to play an audio file when the page loads and has a handful of attributes to control that audio, including balance, volume, loop and the most important of all, the src attribute which refers to the file required.

Note that this is a non-standard element (it was never defined in any standard), and so there is little point in writing it to be XHTML-compliant, as it will never validate.

Example

<head>
 ⋮
 <bgsound src="50_005a08.wav"/>
</head>

Use this for…

Honestly? How about for the purposes of irritating the user as soon as they hit the page? The bgsound element is not a nice one to use, as it foists a noise on the user that they may not be expecting/wanting and may find embarrassing (depending on the site visited!); also, the user has no control over that audio, other than quickly hitting the back button. Then there’s the small matter of compatibility …

Compatibility

Internet Explorer Firefox Safari Opera
5.5 6.0 7.0 1.0 1.5 2.0 1.3 2.0 3.0 9.2 9.5
Full Full Full None None None None None None None None

This element is an Internet Explorer invention and not in any W3C standard and is only supported by Internet Explorer. If you want to include sound on a page, you would be better off embedding it with the object or embed element, contained in a Flash movie with audio controls that the user can manipulate, but even then be aware that a background sound is potentially going to annoy some visitors regardless of how it’s implemented.

In this Section

User-contributed notes

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

Search