CSS Portal

HTML loop Attribute

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

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

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 information will show you the current browser support for the HTML loop attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.

This attribute is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 29th March 2024

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!