- Web templates
- E-commerce Templates
- CMS & Blog Templates
- Facebook Templates
- Website Builders
JS Animated. How to add a background music using HTML
January 26, 2015
This tutorial shows how to add a background music using HTML 5.
JS Animated. How to add a background music using HTMLThe HLTM5 Audio Tag can be used to add background music to any website. The code provided in this tutorial will work on any platform. I will demonstrate the HTML5 Audio functionality.
In this tutorial we will add the HTML5 Audio tag to preload the song and to display the audio controls, autoplay and loop.
The audio tag code will look like the following:
We will add the audio track in both mp3 and ogg format, so that we can get cross browser compatibility. Not all browsers support mp3 and not all browsers support ogg. But using them together we can cover all major browsers.
If you have your audio file in mp3 format, we recommend using an open source tool like Audacity to convert the file to ogg format. So, our code now looks like this:
Change the src to use your own files.
If you want to get the exact same style used in this tutorial, you can get the entire code below:
In order to add the code, you should do the following:
Open html file to edit and paste the code to the desired location in the file:
Save changes in the file.
Upload audio files to the website root folder:
Make sure to update the paths to your audio files in the code you have copied:
Now the background audio is on your web page:
![JS_-Animated.How_to_add_a_background_music_using_HTML_5--2](/help/wp-content/uploads/2014/11/JS_-Animated.How_to_add_a_background_music_using_HTML_5-2-300x171.jpg)
Feel free to check the detailed video tutorial below:
JS Animated. How to add a background music using HTMLIn case you are looking for beautiful wordpress themes music selection, feel free to observe them now!