bgsound (HTML element)
Example
<head> ⋮ <bgsound src="50_005a08.wav"/> </head>
- Type
- head element
- Contains
- nothing
- Contained by
head
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.
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
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | None |
| 1.5 | None | |
| 2.0 | None | |
| Safari | 1.3 | None |
| 2.0 | None | |
| 3.0 | None | |
| Opera | 9.2 | None |
| 9.5 | 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.
User-contributed notes
There are no comments yet.
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.

