HTML | DOM Style borderImageSlice Property
The borderImageSlice property is used to specify the inward offsets of the image border. The user can specify the value of this property in terms of percentage, number or global values.
Syntax:
object.style.borderImageSlice = "number|%|fill|initial|inherit"
Property Values:
- number
- %
- fill
- initial
- inherit
- number: The borderImageSlice property can take the number as the value where this number represents the pixels in the image or vector coordinates (if the image is vector image).
Example-1:
<!DOCTYPE html><html><head><style>div {background-color: green;border: 30px solid transparent;border-image: url(border-image-slice: 40;border-image-width: 1 1 1 1;border-image-outset: 0;border-image-repeat: round;}</style></head><body><center><divid="main"><p>GeeksforGeeks :A computer science portal for geeks.</p></div><pstyle="color:green;">Click below</p><buttononclick="myFunction()">Change</button></center><script>function myFunction() {document.getElementById("main").style.borderImageSlice = "30";}</script></body></html>chevron_rightfilter_noneOutput:
- Before the click:
- After the click:
- Before the click:
- percentage(%): Percentage are relative to the size of the image whose default value is 100%.
Example-2:<!DOCTYPE html><html><head><style>div {background-color: green;border: 30px solid transparent;border-image: url(border-image-slice: 40;border-image-width: 1 1 1 1;border-image-outset: 0;border-image-repeat: round;}</style></head><body><center><divid="main"><p>GeeksforGeeks :A computer science portal for geeks.</p></div><pstyle="color:green;">Click below</p><buttononclick="myFunction()">Change</button></center><script>function myFunction() {document.getElementById("main").style.borderImageSlice = "30% 30%";}</script></body></html>chevron_rightfilter_noneOutput:
- Before the click:
- After the click:
- Before the click:
- fill: It causes the middle part of the border to be preserved.
Example-3:<!DOCTYPE html><html><head><style>div {background-color: green;border: 30px solid transparent;border-image: url(border-image-slice: 40;border-image-width: 1 1 1 1;border-image-outset: 0;border-image-repeat: round;}</style></head><body><center><divid="main"><p>GeeksforGeeks :A computer science portal for geeks.</p></div><pstyle="color:green;">Click below</p><buttononclick="myFunction()">Change</button></center><script>function myFunction() {document.getElementById("main").style.borderImageSlice = "fill";}</script></body></html>chevron_rightfilter_noneOutput:
- Before the click:
- After the click:
- Before the click:
- initial: Set the property to its default value. Here the default value is 100%.
Example-4:<!DOCTYPE html><html><head><style>div {background-color: green;border: 30px solid transparent;border-image: url(border-image-slice: 40;border-image-width: 1 1 1 1;border-image-outset: 0;border-image-repeat: round;}</style></head><body><center><divid="main"><p>GeeksforGeeks :A computer science portal for geeks.</p></div><pstyle="color:green;">Click below</p><buttononclick="myFunction()">Change</button></center><script>function myFunction() {document.getElementById("main").style.borderImageSlice = "initial";}</script></body></html>chevron_rightfilter_noneOutput:
- Before the click:
- After the click:
- Before the click:
- inherit: Inherits this property from its parent element.
Example-5:<!DOCTYPE html><html><head><style>div {background-color: green;border: 30px solid transparent;border-image: url(border-image-slice: 40;border-image-width: 1 1 1 1;border-image-outset: 0;border-image-repeat: round;}</style></head><body><center><divid="main"><p>GeeksforGeeks :A computer science portal for geeks.</p></div><pstyle="color:green;">Click below</p><buttononclick="myFunction()">Change</button></center><script>function myFunction() {document.getElementById("main").style.borderImageSlice = "inherit";}</script></body></html>chevron_rightfilter_noneOutput:
- Before the click:
- After the click:
- Before the click:
Supported Browsers: The supported browser by DOM Style borderImageSlice Property listed below:
- Google Chorme
- Edge
- Mozilla Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM Style top Property
- HTML | DOM Style right Property
- HTML | DOM Style backgroundSize Property
- HTML | DOM Style borderColor Property
- HTML | DOM Style alignSelf Property
- HTML | DOM Style borderBottomLeftRadius Property
- HTML | DOM Style borderImage Property
- HTML | DOM Style boxShadow Property
- HTML | DOM Style borderRightWidth Property
- HTML | DOM Style borderLeftStyle Property
- HTML | DOM Style borderRightStyle Property
- HTML | DOM Style backgroundRepeat Property
- HTML | DOM Style outline Property
- HTML | DOM Style columnRuleStyle Property
- HTML | DOM Style outlineWidth 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.



