Computer >> Computer tutorials >  >> Programming >> HTML

How to add an audio player to an HTML webpage?


The HTML <audio> element is used to add audio to web page. To add an audio player, add the controls attribute.

The following three audio formats are supported in HTML − MP3, Wav, and Ogg.

How to add an audio player to an HTML webpage?

Example

You can try to run the following code to add an audio player to an HTML web page

<!DOCTYPE html>
<html>
   <head>
      <title>HTML audio Tag</title>
   </head>
   <body>
      <p>Click on Play button...</p>
      <p>(Song: Kalimba which is provided as a Sample Music in Windows)</p>
      <audio controls>
         <source src = "/html/Kalimba.mp3" type = "audio/mpeg">
      </audio>
   </body>
</html>