HTML | DOM Style borderImageRepeat Property

The borderImageRepeat property in HTML DOM is used to set or return the borderImageRepeat property. It specifies whether the border-image should repeat to fill the area, stretched to fill the area, set to the initial value, inherit property from its parent, etc. Depending on the need it will set accordingly to make the image border look more attractive.

Syntax:

  • It returns the borderImageRepeat property.
    object.style.borderImageRepeat
  • It sets the borderImageRepeat property.
    object.style.borderImageRepeat="stretch|repeat|round|
    initial|inherit"

Return value: It returns the border image repeat property.

Property Values:

  • stretch: This property is used to stretch the image to fill the area. It is the default value.

    Syntax:

    object.style.borderImageRepeat="stretch";

    Example:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
          
    <head>
        <style>
            #GFG {
                border: 20px solid transparent;
                width: 200px;
                padding: 10px 20px;
                  
                /* For Safari Browser */
                -webkit-border-image: url(
                50 50 round;
                  
                /* For Opera Browser */
                -o-border-image: url(
                50 50 round;
                  
                border-image: url(
                50 50 round;
            }
        </style>
    </head>
      
    <body>
          
        <div id = "GFG">
            <h1>GeeksforGeeks</h1>
        </div><br>
          
        <button onclick = "myGeeks()">
            Click Here!
        </button>
          
        <p>
            Click on button to change property
        </p>
          
        <script>
            function myGeeks() {
                  
                /* For Safari Browser */
                document.getElementById("GFG").style.WebkitBorderImage = 
                50 50 stretch";
                  
                /* For Opera Browser */
                document.getElementById("GFG").style.OBorderImage = 
                50 50 stretch";
                  
                document.getElementById("GFG").style.borderImage = 
                50 50 stretch";
            }
        </script>
      
    </body>
    </html>                    

    chevron_right

    
    

    Output:
    Before click on the button:

    After click on the button:

  • repeat: This property is used to repeat the border image to fill the area.

    Syntax:

    object.style.borderImageRepeat =  "repeat";

    Example:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
          
    <head>
        <style>
            #GFG {
                border: 15px solid transparent;
                width: 200px;
                padding: 10px 20px;
                  
                /* For Safari Browser */
                -webkit-border-image: url(
                50 50 stretch;
                  
                /* For Opera Browser */
                -o-border-image: url(
                50 50 stretch;
                  
                border-image: url(
                50 50 stretch;
            }
        </style>
    </head>
      
    <body>
          
        <div id = "GFG">
            <h1>GeeksforGeeks</h1>
        </div><br>
          
        <button onclick="myGeeks()">
            Click Here!
        </button>
          
        <p>
            Click on button to change property
        </p>
          
        <script>
            function myGeeks() {
                  
                /* For Safari Browser */
                document.getElementById("GFG").style.WebkitBorderImage = 
                50 50 repeat";
                  
                /* For Opera Browser */
                document.getElementById("GFG").style.OBorderImage = 
                50 50 repeat";
                  
                document.getElementById("GFG").style.borderImage = 
                50 50 repeat";
            }
        </script>
    </body>
      
    </html>                    

    chevron_right

    
    

    Output:
    Before click on the button:

    After click on the button:

  • round: It is used to repeat the image to fill the area. If the image doesn’t fill the area in whole number of tiles the image is rescaled.

    Syntax:

    object.style.borderImageRepeat = "round";

    Example:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
          
    <head>
        <style>
            #GFG {
                border: 15px solid transparent;
                width: 200px;
                padding: 10px 20px;
                  
                /* For Safari Browser */
                -webkit-border-image: url(
                50 50 stretch;
                  
                /* For Opera Browser */
                -o-border-image: url(
                50 50 stretch;
                  
                border-image: url(
                50 50 stretch;
            }
        </style>
    </head>
      
    <body>
          
        <div id = "GFG">
            <h1>GeeksforGeeks</h1>
        </div><br>
          
        <button onclick="myGeeks()">
            Click Here!
        </button>
          
        <p>
            Click on button to change property
        </p>
          
        <script>
            function myGeeks() {
                  
                /* For Safari Browser */
                document.getElementById("GFG").style.WebkitBorderImage = 
                50 50 round";
                  
                /* For Opera Browser */
                document.getElementById("GFG").style.OBorderImage = 
                50 50 round";
                  
                document.getElementById("GFG").style.borderImage = 
                50 50 round";
            }
        </script>
    </body>
      
    </html>                    

    chevron_right

    
    

    Output:
    Before click on the button:

    After click on button:

  • space: The only difference with the repeat value is that if it does not fill the area with a whole number of tiles, then extra space is distributed around the tiles.

    Syntax:

    object.style.borderImageRepeat = "space";

    Example:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
    <head>
        <style>
            #GFG {
                border: 15px solid transparent;
                width: 200px;
                padding: 10px 20px;
                  
                /* For Safari Browser */
                -webkit-border-image: url(
                50 50 stretch;
                  
                /* For Opera Browser */
                -o-border-image: url(
                50 50 stretch; 
                  
                border-image: url(
                50 50 stretch;
            }
        </style>
    </head>
      
    <body>
          
        <div id="GFG">
            <h1>GeeksforGeeks</h1>
        </div><br>
          
        <button onclick="myGeeks()">
            Click Here!
        </button>
          
        <p>
            Click on button to change property
        </p>
          
        <script>
            function myGeeks() {
                  
                /* For Safari Browser */
                document.getElementById("GFG").style.WebkitBorderImage = 
        50 50 space"; 
          
                /* For Opera Browser */
                document.getElementById("GFG").style.OBorderImage = 
            50 50 space";
                document.getElementById("GFG").style.borderImage = 
            50 50 space";
            }
        </script>
    </body>
      
    </html>                    

    chevron_right

    
    

    Output:
    Before click on button:

    After click on button:

  • initial: It is used to set borderImageRepeat property to its default value.
  • inherit: It is used to set borderImageRepeat property from its parent element.

Browser Support: The browser supported by DOM style borderImageRepeat property are listed below:

  • Google Chrome
  • Internet Explorer 11.0
  • Mozila firefox
  • Safari 6.0


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.