CSS Portal

CSS border-image-width Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The border-image-width property controls how thick the image-based border appears by specifying how much of the source image’s edges are used and painted along each side of the element’s frame. Conceptually it sets the thickness of the nine-slice “edge” regions of the border image: larger widths make the decorative image edges occupy more space around the element, while smaller widths reduce that painted band and let more of the element’s content/padding area remain visible. Because it defines the area of the image that becomes the border, it directly influences how the image is scaled or tiled when painted along the four edges and in the corners.

This property works together with the other parts of the border-image system. The shorthand border-image bundles the related settings, while border-image-source provides the image to use and border-image-slice determines how that image is partitioned into corner and edge pieces. How the edge pieces are repeated or stretched along each side is controlled by border-image-repeat, and whether the painted border extends beyond the border box can be affected by border-image-outset. Together these properties decide the final appearance: the slice cuts the image, this property specifies how thick those cut edges are when painted, and repeat/outset controls tiling and placement.

Because border images replace or augment the usual framed border, border-image-width also interacts with the conventional border properties. If there is no visible border (for example, because border-style is set to none or the computed border-width is zero), the border image will not be painted in the typical way. Additionally, the widths chosen can affect layout and visual balance: wider image borders reduce the space available for content inside the box and change how corner graphics align with the element’s box edges, so designers should consider how these widths relate to any declared border widths and the element’s padding when planning responsive or precise layouts.

In practice, authors use border-image-width to tune the visual weight of an image border independently of the image’s intrinsic slice positions - for example, to make an ornate frame appear thicker or thinner without editing the source image. Because the value can be set differently per side, it also enables asymmetric framing effects (thicker top border, thinner sides, etc.). When combined thoughtfully with the slice, repeat, and outset settings, controlling the image border width gives fine control over both the aesthetic and the way the image is fitted to varying element sizes.

Definition

Initial value
1
Applies to
All elements
Inherited
No
Computed value
four values, each a percentage, number, 'auto' keyword, or <length> made absolute
Animatable
No
JavaScript syntax
object.style.borderImageWidth

Interactive Demo

Example of the border-image-outset property.

Syntax

border-image-width: [ <length> | <percentage> | <number> | auto ]{1,4}

Values

  • <number>Numbers represent multiples of the corresponding computed border-width.
  • <length>
  • <percentage>Percentages refer to the size of the border image area: the width of the area for horizontal offsets, the height for vertical offsets.
  • autoIf 'auto' is specified then the border image width is the intrinsic width or height (whichever is applicable) of the corresponding image slice. If the image does not have the required intrinsic dimension then the corresponding border-width is used instead.

Example

<div class="wrapper">
<h2>border-image-width example</h2>
<div class="border-box">
<p>Border image with different widths on each side.</p>
</div>
</div>
.wrapper {
  max-width: 520px;
  margin: 40px auto;
  font-family: Arial, sans-serif;
  text-align: center;
}

.border-box {
  border: 40px solid transparent;
  padding: 20px;
  border-image-source: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'><rect width='100' height='100' fill='none' stroke='orange' stroke-width='10'/><line x1='0' y1='0' x2='100' y2='100' stroke='gold' stroke-width='6'/><line x1='100' y1='0' x2='0' y2='100' stroke='gold' stroke-width='6'/></svg>");
  border-image-slice: 30;
  border-image-width: 10px 20px 30px 40px;
  border-image-repeat: stretch;
  background: #fff8e1;
  border-radius: 4px;
}

h2 {
  margin-bottom: 20px;
}

.border-box p {
  margin: 0;
  color: #333;
  font-size: 16px;
}

Browser Support

The following information will show you the current browser support for the CSS border-image-width property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!