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.
Example
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
Tablets & Mobile
Last updated by CSSPortal on: 29th March 2024
