How To Put Background Music On A Website

Table of contents:

How To Put Background Music On A Website
How To Put Background Music On A Website

Video: How To Put Background Music On A Website

Video: How To Put Background Music On A Website
Video: How To Add Background Music To Any HTML Webpage! 2024, December
Anonim

Defines a music file tag. The duration of the sound, the volume of the music and additional characteristics are determined using the attributes of the tag, or can be controlled by scripts. The tag is placed only in the section.

How to put background music on a website
How to put background music on a website

Instructions

Step 1

Go to the page where you want to install the music. Open its code and add the following line to the container:. The attributes are parameters such as balance, loop, src and volume. The first one adjusts the volume of the sound in the right and left speakers. It doesn't change dynamically using scripts. The loop attribute sets the number of times the music file has been played. If this value is missing, the music is played only once. The scr attribute specifies the path to the music file. Valid file extensions vary by browser. Popular formats such as MIDI are supported without installing third party plugins. The last attribute volume is responsible for the volume of the sound. By default, the sound volume is maximum and depends on the settings of the operating system and hardware. Therefore, the sound level can only be decreased by assigning a negative or positive value to the attribute.

Step 2

Set the attributes to values that suit your requirements. It is not necessary to register all the attributes, it is enough to specify the path to the file (src). In this case, the settings will be default. For example: Or come up with something of your own:

Step 3

An alternative way that will make music play in any browser is the following. The downside of this is the use of JavaScript.var MSIE = navigator.userAgent.indexOf ("MSIE"); var OPER = navigator.userAgent.indexOf ("Opera"); var NETS = navigator.userAgent.indexOf ("Netscape"); if ((MSIE> -1) || (OPER> -1)) {document.write ("); // path to file} else {document.write ("); // attribute values}

Recommended: