👀 Live Preview
The modern way to add sound—a visible <audio> player:

By the end of this tutorial, you’ll understand legacy background sound markup and what to use instead in modern HTML.
How <bgsound> auto-played audio via a src attribute.
Understand loop, volume, and balance from old Internet Explorer.
Why <bgsound> is not part of HTML5 and is ignored today.
Compare legacy auto-play with the modern <audio> element.
Use <audio> with controls, loop, and muted.
Recognize bgsound in old tutorials and migrate to HTML5 audio.
<bgsound> Tag?The <bgsound> element was a non-standard, IE-specific void tag that pointed to a sound file via src. The browser played it automatically in the background with no visible controls.
Do not use <bgsound> in new projects. Modern browsers ignore it. Use the HTML5 <audio> element with controls so users can play, pause, and mute.
In the 1990s and early 2000s, developers used <bgsound> for ambient music and sound effects. Today the same goals are met with <audio>, which supports user controls and cross-browser formats.
<audio src="/audio/count.mp3" controls loop muted>
Your browser does not support the audio element.
</audio>Legacy HTML placed <bgsound> in the document body with a src pointing to an audio file:
<bgsound src="soundfile.wav"><bgsound> is a void element—no closing tag or inner content.| Attribute | Code Snippet | Notes |
|---|---|---|
src | <bgsound src="file.wav"> | URL to WAV, MIDI, or MP3 (IE only) |
loop | loop="infinite" | Repeat sound continuously (IE only) |
volume | volume="50" | 0–100 volume level (IE only) |
balance | balance="0" | Stereo balance -100 to 100 (IE only) |
Modern loop | <audio loop> | Boolean attribute on HTML5 audio |
Modern controls | <audio controls> | User-visible play/pause/mute UI |
<bgsound> vs <audio>The HTML5 <audio> element replaced background sound with a cross-browser, user-controlled API:
| Feature | <bgsound> | <audio> |
|---|---|---|
| Status | Deprecated, IE-only | HTML5 standard, all modern browsers |
| User controls | None | controls attribute |
| Autoplay | Always on page load | autoplay + usually muted |
| Loop | loop="infinite" | Boolean loop attribute |
| Accessibility | No pause UI | Users can stop playback |
<!-- Legacy (do not use) -->
<bgsound src="background_music.mp3" loop="infinite">
<!-- Modern replacement -->
<audio src="/audio/count.mp3" controls loop muted>
Your browser does not support the audio element.
</audio>Internet Explorer recognized these attributes on <bgsound>:
src RequiredURL of the sound file to play on page load.
src="/audio/count.mp3"loop IE onlySet to infinite to repeat the sound continuously.
loop="infinite"volume IE onlyVolume level from 0 to 100.
volume="50"balance IE onlyStereo balance from -100 (left) to 100 (right).
balance="0"<bgsound src="/audio/count.mp3" loop="infinite">All bgsound attributes are historical only. The entire element is deprecated and ignored by modern browsers.
Historical bgsound patterns plus the modern <audio> replacement. Legacy examples are for learning only—they will not play in modern browsers.
The modern way to add sound—a visible <audio> player:
How <bgsound> looked in old HTML. For learning only—it will not play in modern browsers.
<bgsound src="/audio/count.mp3">In the 1990s and early 2000s, developers used <bgsound> for ambient music and sound effects. Today the same goals are met with <audio>.
IE supported loop="infinite" to repeat background music. The <audio> tag uses the boolean loop attribute instead.
<bgsound src="/audio/count.mp3" loop="infinite">This is what beginners should use today. The controls attribute gives users a play/pause button; add muted if you need autoplay.
<audio src="/audio/count.mp3" controls autoplay loop muted>
Your browser does not support the audio element.
</audio>Point src at a WAV, MIDI, or MP3 file in the page body.
Internet Explorer started playback automatically with no visible player.
The <audio> element brought cross-browser sound with user controls.
Learn bgsound for history. Build real projects with the <audio> tag.
<bgsound> was Internet Explorer only. Modern browsers never supported it and ignore the tag entirely.
Chrome, Firefox, Safari, Edge, and Opera never implemented <bgsound>. Only legacy Internet Explorer played background sound this way.
No user controls, poor accessibility, and HTML5 audio made the tag obsolete.
Bottom line: Do not use <bgsound> in new projects. Use the HTML5 <audio> element instead.
The <bgsound> tag is a piece of web history—useful to recognize in old code, but not for new sites. Beginners should learn the <audio> tag for all webpage sound, always include controls, and respect modern autoplay policies with muted when needed.
<audio> for all sound in new projectscontrols so users can pause or mute<audio>bgsound only to read legacy HTML<bgsound> in any new HTML code<bgsound>Bookmark these before you ship — they’ll keep you on the modern HTML5 path.
<bgsound> played background audio in old IE only—not part of HTML5.
No visible controls—users could not pause or mute background music.
BehaviorHTML5 <audio> with controls is the modern replacement.
loop="infinite" on bgsound became boolean loop on audio.
Chrome, Firefox, Safari, Edge, and Opera never supported bgsound.
CompatibilityModern browsers require muted for autoplay policies.
<audio> element. Use controls, and optionally autoplay, loop, and muted.<audio> for real projects.Skip deprecated bgsound. Practice background audio with the HTML5 audio tag in the Try It editor.
6 people found this page helpful