Home Full Music Tool Local Home Forum

Add Music to Your Web Site

Free code to add background music

Adding background music or a media player to your website enhances the visitor experience for the right type of site (music blogs, entertainment, event sites). Here are two ways to do it.

Method 1: HTML5 Audio Player (Recommended)

The modern standard. This displays a compact audio player that visitors control themselves:

<audio controls autoplay loop>
  <source src="your-music.mp3" type="audio/mpeg">
  <source src="your-music.ogg" type="audio/ogg">
  Your browser does not support the audio element.
</audio>

Upload your MP3 file to your hosting, replace your-music.mp3 with the actual filename, and paste this code wherever you want the player to appear.

Method 2: Hidden Autoplay (Old Style)

This plays music automatically when the page loads, without showing a player. Note: modern browsers block autoplay audio by default unless the user has interacted with the page.

<audio autoplay loop style="display:none;">
  <source src="your-music.mp3" type="audio/mpeg">
</audio>

Ajax-Based Music Player

For an advanced Ajax-based media player that loads tracks without page reload, see: Ajax Media & Music Player

More free webmaster tools: Free Hit Counter  |  Email Protection Script  |  Free Templates