0
Someone please share with me the code that enables someone to download a song on a website by clicking on it
3 Answers
+ 6
<a href="/songs/song.mp3" download>Download mp3</a>
you can simply use download attribute on <a> tag
https://www.w3schools.com/tags/att_a_download.asp
+ 5
You can use <audio> tag of html5 to add music to your website.
<!DOCTYPE html>
<html>
<body>
<audio controls>
<source src="horse.ogg" type=âaudio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>
audio controls will give your audio file the controls like play, pause or download the audio.
The source tag will allow us to specify alternative audio files which the browser may choose from. The browser will use the first recognized format.
Any other text written between audio tags will be displayed only if the browser doesn't support audio.
0
Thanks guys