bgsound (HTML element)
| Depr. | Empty | Version |
|---|---|---|
| No | Yes | N/A |
| IE5.5+ | FF2 | SA4 | OP10 | CH2 |
|---|---|---|---|---|
| Full | None | None | None | None |
Syntax
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…
Embedding a sound in the
page which starts running on page load (but at the risk of upsetting
users!). The bgsound element is not really 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, given that it’s IE-only.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | Chrome | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| Full | Full | Full | Full | None | None | None | 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.
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.