HTML audio Tag loop Attribute Tutorial

In this section, we will learn what loop attribute is in HTML <audio> element.

What is loop Attribute in HTML audio Tag?

When adding an <audio> element to a webpage and hit the play button, the audio file will play only once! So basically each time you want to lesson to the music, you need to hit the play button again.

But with the help of `loop` attribute, we can set an audio file to play in a loop. This means every time the music reached to the end of itself, it will replay and start from the beginning.

HTML loop Attribute in audio Tag Syntax:

<audio src ="audio-file-address" loop> </audio>

audio Tag loop Attribute Values

The `loop` attribute does not take any argument as its value and we only need to add the attribute to the opening tag of HTML <audio>.

Example: using loop attribute in HTML audio tag

See the Pen using loop attribute in HTML audio tag by Omid Dehghan (@odchan1) on CodePen.


Top Technologies