Audio tags in HTML

The audio tag is used to embedding some audio in a webpage.

alt attribute is not supported in audio tag. So we use different method in audio tag.

By using <audio>...</audio>.

  • Inside audio tag use source tag .
  • Source tag play the audio .
There are two type of playing audio in HTML:
  • Use <audio src="address.mp3" controls> This is a song </audio>  .
  • Use <audio controls> <source src="address.mp3> This is a song  </audio>  .

Case-1:

<!DOCTYPE html>
<html>
<head>
     <title>
         audio tag
     </title>
</head>
<body>
     <audio src="C:\Users\avengers\Music\Khairiyat Happy - Chhichhore.mp3controls></audio>
</body>
</html>


Note: Controls attribute gives the audio interface.

If the browser doesn't support audio .It displays the message which is given inside audio tag ,that displays in the browser.


Output:

Audio tag
Audio tag 

Case-2:

<!DOCTYPE html>
<html>
<head>
      <title>
        audio tag
     </title>
</head>
<body>
      <audio controls>
       <source src="C:\Users\avengers\Music\Khairiyat Happy - Chhichhore.mp3type="audio/mp3">
       This is a song.Your browser not supporting audio
      </audio>
</body>
</html>

If the browser doesn't support audio .It displays the message which is given inside audio tag ,that displays in the browser. 
  • You can give multiple source , if the first audio is not support then it will play second audio.This is the main important of using source tag.
  • Suppose if all videos not support then the text in video tag will display.

Post a Comment

Post a Comment (0)

Previous Post Next Post