Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Borders, Outlines and Shadows

The border-image-width property

Reference for the CSS border-image-width property: set how thick the drawn border image is using numbers, lengths, percentages or auto, with live examples.

The border-image-width property sets the size of the area in which the border image is drawn. The four slices of the source image are scaled to fit this area. By default the width is 1, meaning exactly as thick as the element's border-width, so the drawn border and the space reserved for it match.

You can make the image thicker or thinner than the real border. This does not change layout: the box still reserves space from border-width, so a wider image can overlap the content or padding.

CSS
.frame {
  border: 20px solid;
  border-image-width: 2;
}

Try it

Image width versus border width

Syntax

CSS
border-image-width: [ <length-percentage [0,โˆž]> | <number [0,โˆž]> | auto ]{1,4};
  • Initial value: 1
  • Applies to: all elements, except internal table elements when border-collapse is collapse
  • Inherited: no
  • Animatable: yes, by computed value
  • Computed value: four values, each a percentage, auto, or a number or absolute length

Values

Value Description
<number> A multiple of the matching border-width. 1 is the default.
<length> A fixed thickness such as 12px.
<percentage> Relative to the border image area (width for left and right, height for top and bottom).
auto Use the intrinsic size of the matching slice of the image.
One to four values Top, right, bottom, left, in the usual shorthand pattern.

Usage notes

  • Unitless numbers are multipliers, not pixels. If border-width is 0, a unitless width becomes 0 too and nothing is drawn.
  • No layout effect. Only border-width and padding affect size. A thicker image can cover text, so check the result.
  • Width versus slice. If the drawn border is thinner or thicker than the slice, the image is scaled; keep the proportions in mind to avoid distortion.
  • Overlap rule. When the left and right widths together exceed the box width, all widths shrink proportionally.
  • In the shorthand the width comes after the slice and a slash: border-image: url(frame.svg) 30 / 20px.

Browser support

Supported in every current browser.