Open In App

HTML DOM Style borderImageRepeat Property

Last Updated : 25 Aug, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The borderImageRepeat style 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 be 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: 

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

Syntax: 

object.style.borderImageRepeat = "stretch";

Example: 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <style>
        #GFG {
            border: 20px solid transparent;
            width: 200px;
            padding: 10px 20px;
 
            /* For Safari Browser */
            -webkit-border-image:
 
            /* For Opera Browser */
            -o-border-image:
 
            border-image:
        }
    </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 =
 
            /* For Opera Browser */
            document.getElementById("GFG")
                .style.OBorderImage =
 
            document.getElementById("GFG")
                .style.borderImage =
        }
    </script>
</body>
 
</html>


Output: 

borderImageRepeat

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

Syntax: 

object.style.borderImageRepeat =  "repeat";

Example: 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <style>
        #GFG {
            border: 20px solid transparent;
            width: 200px;
            padding: 10px 20px;
 
            /* For Safari Browser */
            -webkit-border-image:
 
            /* For Opera Browser */
            -o-border-image:
 
            border-image:
        }
    </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 =
 
            /* For Opera Browser */
            document.getElementById("GFG")
                .style.OBorderImage =
 
            document.getElementById("GFG")
                .style.borderImage =
        }
    </script>
</body>
 
</html>


Output: 

borderImageRepeat2

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

Syntax: 

object.style.borderImageRepeat = "round";

Example: 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <style>
        #GFG {
            border: 20px solid transparent;
            width: 200px;
            padding: 10px 20px;
 
            /* For Safari Browser */
            -webkit-border-image:
 
            /* For Opera Browser */
            -o-border-image:
 
            border-image:
        }
    </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 =
 
            /* For Opera Browser */
            document.getElementById("GFG")
                .style.OBorderImage =
 
            document.getElementById("GFG")
                .style.borderImage =
        }
    </script>
</body>
 
</html>


Output: 

borderImageRepeat3

4. 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: 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <style>
        #GFG {
            border: 20px solid transparent;
            width: 200px;
            padding: 10px 20px;
 
            /* For Safari Browser */
            -webkit-border-image:
 
            /* For Opera Browser */
            -o-border-image:
 
            border-image:
        }
    </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 =
 
            /* For Opera Browser */
            document.getElementById("GFG")
                .style.OBorderImage =
 
            document.getElementById("GFG")
                .style.borderImage =
        }
    </script>
</body>
 
</html>


Output: 

borderImageRepeat4

5. initial: It is used to set borderImageRepeat property to its default value.

6. 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 15
  • Edge 12
  • Internet Explorer 11
  • Mozilla firefox 15
  • Opera 15
  • Safari 6


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads