
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to add background music to your web page?
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.
Example
You can try to run the following code to add background music to your web page:
<!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>
- Related Articles
- How to add Google Charts to your web page?
- How to add background music in HTML?
- How to add Scalable Vector Graphics (SVG) to your Web Page?
- How to use Google Fonts on your web page?
- How to play sound file in a web-page in the background?
- How to play background music in Android app?
- Change Background color of a web page using onmouseover property
- What is Android background music service?
- How to automatically redirect a Web Page to another URL?
- How to completely fill web page with HTML canvas?
- How to automatically redirect your visitors to your new home page?
- How to create a full-page background image with CSS?
- How to add video in HTML page?
- How to add background Image to JFrame in Java
- How to get the protocol and page path of the current web page in JavaScript?

Advertisements