+ 1
how we can insert music on html and html5
3 Answers
+ 8
To play an audio file in HTML, use theĀ <audio> element:
Example:
<audioĀ controls>
Ā Ā <sourceĀ src="horse.ogg" type="audio/ogg">
<sourceĀ src="horse.mp3" type="audio/mpeg">
</audio>
TheĀ controlsĀ attribute adds audio controls, like play, pause, and volume.
MultipleĀ <source>Ā elements can link to different audio files. The browser will use the first recognized format.
The <type> element must be included in <audio>. If the file searched is mp3 the type tag will be type="audio/mpeg". If the file searched is ogg the type tag will be type=" audio/ogg.
Currently, there are 3 supported file formats for the <audio> element: MP3, Wav, and Ogg:
Browser MP3 Wav Ogg
InternetExplorer. YES NO NO
Chrome YES YES YES
Firefox YES YES YES
Safari YES YES NO
Opera YES YES YES
HTML5 Audio tags:
<audio> - Defines sound content
<source> - Defines multiple media resources for media elements, such as <video> and <audio>
- Dumitru
If this answer has helped you, give it a upvote by pressing the button that looks like an thumbs up (like).
+ 1
put your html file and one of your mp3 file in same folder and then put this code in body tag:
<audio controls>
<source src="put your mp3 file name" type="audio/mpeg">
<source src="audio.ogg" type="audio/ogg">
Audio element not supported by your browser
</audio>
+ 1
use the tag <audio src="name of file.extincton" autoplay/controls"type=extiction