HTML <bgsound> Element

The <bgsound> element was a non-standard HTML element historically used to play an audio file automatically in the background of a webpage. It was primarily associated with Internet Explorer and was never part of the standardized HTML specification.

Historical Syntax

Older webpages designed for Internet Explorer may contain markup similar to the following:

<bgsound src="background.mid" loop="infinite">

This code is shown for historical reference only. The <bgsound> element is non-standard and obsolete and should not be used when creating or updating modern HTML.

Attributes

The <bgsound> element historically supported several attributes for controlling background audio. These attributes are obsolete and are included only to help identify and understand older HTML source code.

Attribute Description
balance Controlled the balance of the audio between the left and right speakers.
loop Specified how many times the audio should play. Historical implementations also allowed continuous playback.
src Specified the URL of the audio file that the browser should play.
volume Controlled the playback volume of the background audio in supporting browsers.

Historical Use

The <bgsound> element was introduced by Microsoft and became associated with webpages created for Internet Explorer during the early web. Authors could use it to start playing an audio file when a visitor opened a page, often without displaying any visible playback controls.

MIDI files were commonly used because they were relatively small compared with digital audio files available at the time. Background music became a recognizable feature of many personal and promotional websites from that period.

Why It Became Obsolete

The <bgsound> element was proprietary rather than a standardized HTML feature, so its behavior was not consistently supported across browsers. Modern HTML introduced the standardized <audio> element for embedding audio without relying on browser-specific markup.

Automatically playing background audio can also create usability and accessibility problems. Unexpected sound may be distracting, interfere with screen readers or other audio, consume bandwidth, and leave users searching for a way to stop playback. Modern browsers therefore commonly restrict audible autoplay.

Modern Alternative

Use the <audio> element to provide audio in modern HTML. Adding the controls attribute gives users a visible way to start, pause, seek, and adjust the audio rather than forcing background sound to begin automatically.

<audio controls>
  <source src="audio.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

Although the <audio> element supports an autoplay attribute, audible autoplay should generally be avoided. Browsers may also prevent autoplay unless specific conditions are met.

Legacy Browser Support

The <bgsound> element was primarily supported by Internet Explorer and was not consistently implemented by other browsers. Modern browsers should not be expected to reproduce its historical background-audio behavior.

Older source code may still contain <bgsound>, but browser recognition of historical markup does not make it valid modern HTML. When maintaining an older website, replace necessary audio functionality with the standardized <audio> element and reconsider whether automatic background audio is appropriate at all.

For detailed legacy browser compatibility information, see Can I Use: HTML <bgsound> Element .

Use the <audio> element to embed audio content in modern HTML. The <source> element can provide one or more alternative media resources for an audio element.

Specifications

The <bgsound> element is listed as an entirely obsolete, non-conforming feature in the WHATWG HTML Living Standard . Authors should use the <audio> element instead.