HTML loop Attribute

Last Updated : 29 May, 2026

The HTML loop attribute is used to make media replay automatically after it finishes. It is commonly applied to audio and video elements for continuous playback.

  • Repeats media playback automatically when it ends.
  • Can be used with both <audio> and <video> elements.
  • Often combined with attributes like autoplay, muted, and controls.

Syntax:  

<element loop>

Supported Elements

  • <audio>
  • <video>
  • <marquee>
  • <bgsound>


Example 1: Illustrates the use of loop attribute in <audio> element.  

html
<!--Driver Code Starts-->

<!DOCTYPE html>
<html>

<head>
    <title>
        Audio loop Attribute
    </title>
</head>

<!--Driver Code Ends-->

<body style="text-align: center">

    <h1 style="color: green"> 
    GeeksforGeeks 
</h1>
    <h2 style="font-family: Impact"> 
    HTML Audio loop Attribute 
</h2>
    <br>

    <audio id="Test_Audio" 
           controls loop>
        <source src="beep.mp3" 
                type="audio/mpeg">
    </audio>
</body>

<!--Driver Code Starts-->

</html>

<!--Driver Code Ends-->


Example 2: Illustrates the use of loop attribute in <video> element.  

html
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>

<head>
    <title>
      HTML video loop Attribute
  </title>
</head>

<!--Driver Code Ends-->

<body>
    <center>
        <h1 style="color:green;">
          GeeksforGeeks
      </h1>

        <h3>HTML video loop Attribute</h3>

        <video width="400" 
               height="200" 
               controls loop>
          
            <source src="Canvas.move_.mp4"
                    type="video/mp4">
            <source src="Canvas.move_.ogg" 
                    type="video/ogg">
        </video>
    </center>
</body>

<!--Driver Code Starts-->

</html>
<!--Driver Code Ends-->
Comment