loop

The loop attribute in HTML, used with <video> and <audio> elements, allows the media to automatically restart once it finishes playing.

loop attribute

The loop attribute in HTML is a boolean used with <video> and <audio>elements. When added, it makes the media automatically replay from the beginning after finishing, ensuring seamless, continuous playback.

Syntax

index.html
<tagname loop>

Example

index.html
<video controls loop>
  <source src="video.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video>

Values

The loop attribute is a boolean, meaning it doesn't require any associated values.

The loop attribute functions as soon as it is included, without needing a value to be specified.

Applies To

The loop attribute can be applied to the following HTML elements:

Conclusion

The loop attribute in HTML enables media elements such as <video> and <audio> to automatically replay once they’ve finished, providing uninterrupted playback. As a boolean attribute, it does not require a value. This functionality improves the overall user experience for both video and audio content.