HTML Audio Tag

  • Purpose: To embed audio content within an HTML document.
  • Tags: <audio>
  • Attributes
    • src: Specifies the URL or path to the audio file.
    • controls: Displays default audio controls (play, pause, volume, etc.) to the user.
    • autoplay: Starts playing the audio automatically when the page loads. (Note: This attribute may be restricted by browsers due to user experience concerns.)
    • loop: Makes the audio loop indefinitely.
    • muted: Mutes the audio by default.
  • Example:
<audio src="audio.mp3" controls></audio>

This code will embed an audio file named “audio.mp3” and display default audio controls to the user.

Scroll to Top