Video HTML

5 min read

How to Loop Video in HTML?

Explore the concept of how video looping works with HTML and its implementation and discover its various usages. Lastly, learn how to troubleshoot common issues when the HTML video loop doesn't work as expected.

Feature image
How to Loop Video in HTML?
Hello from Gumlet! We have an ad-free video player you can deeply customize without a single line of code. Also, set up autoplay and loop with a single click. With our player, your videos kick off faster than a cheetah on a caffeine high, keeping your audience glued to their screens. We also have a fully stacked video hosting solution to go with it. Level up your video streaming game with Gumlet, Signup now; it's free.

HTML Video Loop

HTML video loop is a relatively new feature in HTML5 that allows browsers to play a particular video repeatedly in a continuous loop. When the loop attribute is added to the code, the user won’t have to restart the video manually. Instead, the video will keep restarting after it ends until the user pauses it manually or navigates away from the page.

A video platform with everything at your fingertips

While the HTML5 video loop feature is not yet fully compatible, most major browsers like Chrome, Firefox, Safari, and Edge have released support versions. But before publishing the web page, it’s always good to test your video on different browsers to see if the attribute is supported.
While there is no limit to the duration of the video that can be looped, it’s best only to use this feature on shorter videos so as not to disrupt the user experience and cause unnecessary data loss.

Code Snippet

Here’s an example of how to prepare a code for looping a video:

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


Here’s a breakdown of the code in detail:

  • The loop attribute is added to the primary <video> tag. It is a boolean attribute.
  • The <video> tag is a basic HTML5 element that allows users to embed video content on any webpage.
  • The controls attribute gives the users specific controls over the video playback. With this feature, users can play, pause, and increase/decrease the volume of the video.
  • The <source> tag is used to determine the URL or the path of the file. The type attribute associated with the source determines the format of the embedded video.

Sometimes, using the loop attribute as complementary to the preload attribute is a good idea. This ensures that the video is loaded smoothly without any issues or delays. If you set the preload attribute to auto, the browser will be compelled to preload the video data when the page loads. This can significantly help decrease buffering and ensure smooth video playback.

Here’s an example of how to use the preload attribute in your code:

<video width="640" height="360" autoplay muted preload="auto" loop poster="video-poster.jpg">
<source src="video.mp4" type="video/mp4">
Your browser does not support the video tag.

Browser Support and Compatibility

Most browsers, especially the latest versions, are compatible with the loop attribute. Here is a list of the earliest browser versions that support this HTML5 feature:

Browser Chrome Edge Firefox Safari Opera
Version 4.0 9.0 11.0 3.1 11.5

Check if your video is optimized for instant start times on auto-play


Despite being a relatively new attribute, the video loop feature has gained significant traction over the last few years. Now, different websites are looping videos on their websites for different purposes. Here is a list of common applications of the HTML video loop feature:

  • Background Videos - A lot of websites run background videos to increase their aesthetic appeal. In such a case, using the video loop feature can be useful. For example, the website for a travel company might be using a one-shot of a beach as its background using the HTML background video loop feature. By looping this video, customers will keep seeing the snippet of the beautiful beach, creating a warm and immersive atmosphere for them.
  • Promotional Videos - Video banners and other advertisements can be looped on a webpage to promote a particular company and its products or services. For example, brands like Nike and Adidas often keep looping videos of superstar athletes associated with them to promote their line of products.
  • Interactive Videos - Interactive videos help users get a more immersive buying experience from certain websites. In most cases, using the loop feature for such videos is mandatory because they must always be accessible to the user. For example, car dealerships might display a looped video of a driving car where users can click on different parts of the vehicle to get more information about specifications.
  • Educational Videos - Educational videos are often looped on different web pages. You might have seen museums where certain informational videos are looped on display for the customers to see and learn more about specific topics.
  • Ambient Videos - Sometimes, atmospheric and ambient elements are used to increase the visual aesthetics of a webpage. These videos are looped to create an effect that matches the website's theme.

HTML Video Loop Not Working?

If your video loop feature is not working, here are the troubleshooting steps that you can take:

  • Check Browser Support: Not all browsers support the loop attribute. Ensure you use the latest version of mainstream browsers compatible with newer HTML5 attributes.
  • Recheck Video Format: The loop feature might not work if the browser does not support the video format. For example, not all browsers are compatible with certain video codecs.
  • Diagnose Video Files: Check the video file that needs to be embedded. It will not work on any webpage if it is damaged or corrupted. One way to do this is to check if the video is playing fine locally.
  • Check for Errors: Look into your browser console to see if there are any video-related errors.
  • Check Compatibility with Different Attributes: Other attributes in the <video> tag might be interfering with the functionality of the loop attribute. As such, ensure that all the attributes, like autoplay or muted, do not result in code conflicts.


The HTML video loop is a powerful tool that can help developers create a dynamic and engaging video experience for users. With the ability to loop certain videos without interruption or engagement requirements, this attribute can be used on multiple fronts to promote strategic efforts to make the website more appealing to the viewers.

However, it’s still important to stay vigilant and limit the use of such attributes that can hamper user experience if overused.


Can I control the number of times a video loops in HTML?
There is no direct control of video loop count with HTML loop attribute. You can use JavaScript to set loops.

Are there performance implications of looping videos in HTML?
Looping videos can drain CPU, memory, battery, and bandwidth. Consider optimizing videos for web use and using appropriate video format to ensure smooth, resource-friendly playback.

Images or Videos Loading Slow?

We compress them so your users don't need to wait.