HTML | DOM Style borderImageWidth Property

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"

Property Values



  • 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 1:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!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>                    

    chevron_right

    
    

    Output:
    Before Click on the button:
    multiple-before
    After Click on the button:
    multiple-after

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

    Example:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!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>                    

    chevron_right

    
    

    Output:
    Before Click on the button:
    multiple-before
    After Click on the button:
    multiple-after

  • 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:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!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>                    

    chevron_right

    
    

    Output:
    Before Click on the button:
    multiple-before
    After Click on the button:
    multiple-after

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

    Example:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!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>                    

    chevron_right

    
    

    Output:
    Before Click on the button:
    multiple-before
    After Click on the button:
    multiple-after

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

    Example:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!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>                    

    chevron_right

    
    

    Output:
    Before Click on the button:
    multiple-before
    After Click on the button:
    multiple-after

  • inherit: It inherits the property from its parent.

    Example:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!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>                    

    chevron_right

    
    

    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
  • Internet Explorer 11
  • Firefox
  • Safari 6


My Personal Notes arrow_drop_up

Technical Writer Lets have an update

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.