Skip to content
Related Articles

Related Articles

HTML | DOM Style borderImageWidth Property

View Discussion
Improve Article
Save Article
  • Last Updated : 09 Aug, 2022
View Discussion
Improve Article
Save Article

The Style borderImageWidth property in HTML DOM is used to set or return the width of the border image. 

Syntax:

  • It returns the borderImageWidth property
object.style.borderImageWidth
  • It is used to set the borderImageWidth property
object.style.borderImageWidth = "number|percentage|auto|
initial|inherit"

Return Values: It returns a string value, that represents the border-image-width property of an element.

Property Values

1. number: It is used to set the width as a multiple of corresponding computed value of border-width. This is the default value when set to 1. 

Example: 

html




<!DOCTYPE html>
<html>
     
<head>
    <title>
        DOM Style borderImageWidth Property
    </title>
     
    <style>
        .item {
            height: 70px;
            border: 10px solid transparent;
            border-image:
            border-image-slice: 60;
            border-image-repeat: round;
            text-align:center;
            padding-top:20px;
            font-size:40px;
            font-weight:bold;
        }
    </style>
</head>
 
<body>
    <h2>
        DOM Style borderImageWidth Property
    </h2>
     
    <p>
        Click on the button to change the
        width of border-image
    </p>
     
    <div class = "item">
        GeeksforGeeks
    </div>
     
    <button onclick = "changeWidth()">
        Click Here!
    </button>
 
    <script>
        function changeWidth() {
            elem = document.querySelector('.item');
 
            // Setting the image width to a multiple of 3
            elem.style.borderImageWidth = '3';
        }
    </script>
</body>
 
</html>                   

Output: 

Before Click on the button: 

multiple-before After Click on the button: 

multiple-after

2. length: It is used to set the width in terms of a length unit. 

Example: 

html




<!DOCTYPE html>
<html>
     
<head>
    <title>
        DOM Style borderImageWidth Property
    </title>
     
    <style>
        .item {
            height: 70px;
            border: 10px solid transparent;
            border-image:
            border-image-slice: 60;
            border-image-repeat: round;
            text-align:center;
            padding-top:20px;
            font-size:40px;
            font-weight:bold;
        }
    </style>
</head>
 
<body>
    <h2>
        DOM Style borderImageWidth Property
    </h2>
     
    <p>
        Click on the button to change the
        width of border-image
    </p>
     
    <div class = "item">
        GeeksforGeeks
    </div>
     
    <button onclick = "changeWidth()">
        Click Here!
    </button>
 
    <script>
        function changeWidth() {
            elem = document.querySelector('.item');
 
            // Setting the image width to a multiple of 3
            elem.style.borderImageWidth = '30px';
        }
    </script>
</body>
 
</html>                   

Output: 

Before Click on the button: 

multiple-before After Click on the button: 

multiple-after

3. percentage: It is used to set the width in terms of percentage. Percentage is relative to the width of the border image area for horizontal offsets and the height of the border image area for vertical offsets. 

Example: 

html




<!DOCTYPE html>
<html>
     
<head>
    <title>
        DOM Style borderImageWidth Property
    </title>
     
    <style>
        .item {
            height: 70px;
            border: 10px solid transparent;
            border-image:
            border-image-slice: 60;
            border-image-repeat: round;
            text-align:center;
            padding-top:20px;
            font-size:40px;
            font-weight:bold;
        }
    </style>
</head>
 
<body>
    <h2>
        DOM Style borderImageWidth Property
    </h2>
     
    <p>
        Click on the button to change the
        width of border-image
    </p>
     
    <div class = "item">
        GeeksforGeeks
    </div>
     
    <button onclick = "changeWidth()">
        Click Here!
    </button>
 
    <script>
        function changeWidth() {
            elem = document.querySelector('.item');
 
            // Setting the image width to a multiple of 3
            elem.style.borderImageWidth = '10%';
        }
    </script>
</body>
 
</html>                   

Output: 

Before Click on the button: 

multiple-before After Click on the button: 

multiple-after

4. auto: It makes width of the border equal to the intrinsic width or height of the corresponding image slice. 

Example: 

html




<!DOCTYPE html>
<html>
     
<head>
    <title>
        DOM Style borderImageWidth Property
    </title>
     
    <style>
        .item {
            height: 70px;
            border: 10px solid transparent;
            border-image:
            border-image-slice: 60;
            border-image-repeat: round;
            text-align:center;
            padding-top:20px;
            font-size:40px;
            font-weight:bold;
        }
    </style>
</head>
 
<body>
    <h2>
        DOM Style borderImageWidth Property
    </h2>
     
    <p>
        Click on the button to change the
        width of border-image
    </p>
     
    <div class = "item">
        GeeksforGeeks
    </div>
     
    <button onclick = "changeWidth()">
        Click Here!
    </button>
 
    <script>
        function changeWidth() {
            elem = document.querySelector('.item');
 
            // Setting the image width to a multiple of 3
            elem.style.borderImageWidth = 'auto';
        }
    </script>
</body>
 
</html>                   

Output: 

Before Click on the button: 

multiple-before After Click on the button: 

multiple-after

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

Example: 

html




<!DOCTYPE html>
<html>
     
<head>
    <title>
        DOM Style borderImageWidth Property
    </title>
     
    <style>
        .item {
            height: 70px;
            border: 10px solid transparent;
            border-image:
            border-image-slice: 60;
            border-image-repeat: round;
            text-align:center;
            padding-top:20px;
            font-size:40px;
            font-weight:bold;
        }
    </style>
</head>
 
<body>
    <h2>
        DOM Style borderImageWidth Property
    </h2>
     
    <p>
        Click on the button to change the
        width of border-image
    </p>
     
    <div class = "item">
        GeeksforGeeks
    </div>
     
    <button onclick = "changeWidth()">
        Click Here!
    </button>
 
    <script>
        function changeWidth() {
            elem = document.querySelector('.item');
 
            // Setting the image width to a multiple of 3
            elem.style.borderImageWidth = 'initial';
        }
    </script>
</body>
 
</html>                   

Output: 

Before Click on the button: 

multiple-before After Click on the button: 

multiple-after

6. inherit: It inherits the property from its parent. 

Example: 

html




<!DOCTYPE html>
<html>
     
<head>
    <title>
        DOM Style borderImageWidth Property
    </title>
     
    <style>
        .item {
            height: 70px;
            border: 10px solid transparent;
            border-image:
            border-image-slice: 60;
            border-image-repeat: round;
            text-align:center;
            padding-top:20px;
            font-size:40px;
            font-weight:bold;
        }
 
        .Geeks {
             
            /* Setting the border-width to of parent */
            border-image-width: 30px;
        }
    </style>
</head>
 
<body>
     
    <h2>
        DOM Style borderImageWidth Property
    </h2>
     
    <p>
        Click on the button to change the
        width of border-image
    </p>
 
    <div class = "Geeks">
        <div class = "item">
            GeeksforGeeks
        </div>
    </div>
     
    <button onclick = "changeWidth()">
        Click Here!
    </button>
 
    <script>
        function changeWidth() {
            elem = document.querySelector('.item');
 
            // Setting the image width to inherit
            elem.style.borderImageWidth = 'inherit';
        }
    </script>
</body>
</html>                   

Output: 

Before Click on the button: 

multiple-before After Click on the button: 

multiple-after

Supported Browsers: The browser supported by borderImageWidth Property are listed below:

  • Chrome 15
  • Edge 12
  • Internet Explorer 11
  • Firefox 13
  • Opera 15
  • Safari 6

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!