crus4

crus4

HTML Audio


HTML <audio> tag is used to play an audio file on a web page. At present there are three formats that are supported for HTML <audio> tag. These are: mp3, wav and ogg.

In the below table, let’s see which browser supports the audio file format.

Browsermp3wavogg
Chrome YesYesYes
EdgeYesYesYes
FirefoxYesYesYes
OperaNoYesYes
SafariYesYesNo

The HTML <audio> Element

In an Example below I will write a code to show you how you can use the audio element.

Example

<!DOCTYPE html>
<html>
<head>
 <title>HTML Audio</title>
</head>
<body>
<audio controls>
  <source src="#sound.ogg" type="audio/ogg">
  <source src="#sound.mp3" type="audio/mpeg">
</audio>
</body>
</html>

Code Explanation

Other Attributes that we can use with the audio tag are:


Related Posts

HTML Video

Images in HTML

HTML Canvas

HTML Audio – crus4