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:
<!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 thewidth of border-image</p><divclass="item">GeeksforGeeks</div><buttononclick="changeWidth()">Click Here!</button><script>function changeWidth() {elem = document.querySelector('.item');// Setting the image width to a multiple of 3elem.style.borderImageWidth = '3';}</script></body></html>chevron_rightfilter_noneOutput:
Before Click on the button:

After Click on the button:
- length: It is used to set the width in terms of a length unit.
Example:
<!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 thewidth of border-image</p><divclass="item">GeeksforGeeks</div><buttononclick="changeWidth()">Click Here!</button><script>function changeWidth() {elem = document.querySelector('.item');// Setting the image width to a multiple of 3elem.style.borderImageWidth = '30px';}</script></body></html>chevron_rightfilter_noneOutput:
Before Click on the button:

After Click on the button:
- 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:
<!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 thewidth of border-image</p><divclass="item">GeeksforGeeks</div><buttononclick="changeWidth()">Click Here!</button><script>function changeWidth() {elem = document.querySelector('.item');// Setting the image width to a multiple of 3elem.style.borderImageWidth = '10%';}</script></body></html>chevron_rightfilter_noneOutput:
Before Click on the button:

After Click on the button:
- auto: It makes width of the border equal to the intrinsic width or height of the corresponding image slice.
Example:
<!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 thewidth of border-image</p><divclass="item">GeeksforGeeks</div><buttononclick="changeWidth()">Click Here!</button><script>function changeWidth() {elem = document.querySelector('.item');// Setting the image width to a multiple of 3elem.style.borderImageWidth = 'auto';}</script></body></html>chevron_rightfilter_noneOutput:
Before Click on the button:

After Click on the button:
- initial: It is used to set borderImageWidth property to its default value.
Example:
<!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 thewidth of border-image</p><divclass="item">GeeksforGeeks</div><buttononclick="changeWidth()">Click Here!</button><script>function changeWidth() {elem = document.querySelector('.item');// Setting the image width to a multiple of 3elem.style.borderImageWidth = 'initial';}</script></body></html>chevron_rightfilter_noneOutput:
Before Click on the button:

After Click on the button:
- inherit: It inherits the property from its parent.
Example:
<!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 thewidth of border-image</p><divclass="Geeks"><divclass="item">GeeksforGeeks</div></div><buttononclick="changeWidth()">Click Here!</button><script>function changeWidth() {elem = document.querySelector('.item');// Setting the image width to inheritelem.style.borderImageWidth = 'inherit';}</script></body></html>chevron_rightfilter_noneOutput:
Before Click on the button:

After Click on the button:
Supported Browsers: The browser supported by borderImageWidth Property are listed below:
- Chrome
- Internet Explorer 11
- Firefox
- Safari 6
Recommended Posts:
- HTML | DOM Style right Property
- HTML | DOM Style top Property
- HTML | DOM Style cursor Property
- HTML | DOM Style tabSize Property
- HTML | DOM Style wordWrap Property
- HTML | DOM Style textDecorationLine Property
- HTML | DOM Style borderRadius Property
- HTML | DOM Style borderTopStyle Property
- HTML | DOM Style textAlign Property
- HTML | DOM Style objectPosition Property
- HTML | DOM Style wordSpacing Property
- HTML | DOM Style marginRight Property
- HTML | DOM Style columnCount Property
- HTML DOM | Style pageBreakAfter Property
- HTML | DOM Style outlineStyle Property
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.



