HTML loop Attribute

Description

The loop attribute in HTML is a boolean attribute used with media elements like <video> and <audio>. When present, it indicates that the media will start over again, automatically, from the beginning once it has finished playing. Essentially, it allows the media to loop continuously until it is explicitly stopped by the user or via JavaScript. This attribute can enhance user experience in specific contexts, such as background videos or ambient music on a webpage, where continuous playback is desired. The syntax for using the loop attribute is straightforward; you simply include it within the opening tag of the <video> or <audio> element, like so: <video src="movie.mp4" loop></video>. Note that the loop attribute does not require a value to be set; its presence alone activates the looping functionality.

Syntax

<tagname loop>

Values

The loop attribute is a boolean attribute, therefore no values are associated with this attribute.

Applies To

The loop attribute can be used on the following html elements.

Example

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

Browser Support

The following table will show you the current browser support for the HTML loop Attribute.

Desktop
Edge Chrome Firefox Opera Safari
YesYesYesYesYes
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
YesYesYesYesYesYes

Last updated by CSSPortal on: 29th March 2024