Autoplay music website

How to add background music to your web page?

JavascriptWeb DevelopmentFront End Scripts

To add background music on a web page, use <embed></embed> element. Also, use the autoplay attribute. This will run music in the background whenever the page loads.

Set the width and height in a way the player hides on the web page. The loop attribute is added to specify whether the audio will start over again. Add the music file to the server and mention the link in src attribute.

Autoplay music website

Example

You can try to run the following code to add background music to your web page:

Live Demo

<!DOCTYPE html> <html> <head> <title>HTML background music</title> </head> <body> <p>The music is running in the background.</p> <p>(Song: Kalimba which is provided as a Sample Music in Windows)</p> <embed src="/html/Kalimba.mp3" loop="true" autostart="true" width="2" height="0"> </body> </html>
Autoplay music website
Vikyath Ram
Published on 23-Apr-2018 10:47:05
Previous Page Print Page
Next Page
Advertisements