How to add background music in HTML?

HTMLJavascriptProgramming Scripts

The HTML <bgsound> tag is used to play music in the background. This tag is for Internet Explorer only.

Example

You can try to run the following code to add background music in HTML −

<!DOCTYPE html>
<html>
   <head>
      <title>HTML bgsound Tag</title>
   </head>
   <body>
      <bgsound src = "/html/yourfile.mdi"/>
      <p>Plays sound file in the background.</p>
   </body>
</html>

The HTML <bgsound> tag also supports the following attributes −

Attribute
Value
Description
loop
number
Lets you replay a background soundtrack a certain number of times.
src
URL
Specifies the path of the sound file.




raja
Published on 13-Mar-2018 11:21:10
Advertisements