TOP CATEGORIES

×

How to add attributes in audio tag?

S

Surbhi

Attributes Used in <audio>

  • controls → Displays play/pause/volume buttons.
  • autoplay → Starts audio automatically (not recommended for UX).
  • loop → Plays audio repeatedly.
  • muted → Starts audio in muted mode.
  • preload → Tells the browser how much of the audio file should be loaded before playback.

How to Add <audio> Attribute in HTML

<audio controls autoplay loop muted preload="auto">

   <source src="music.mp3" type="audio/mpeg">

</audio>

0 votes

Your Answer