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.
.frame { border: 20px solid; border-image-width: 2; }
Try it
Syntax
border-image-width: [ <length-percentage [0,โ]> | <number [0,โ]> | auto ]{1,4};
- Initial value:
1 - Applies to: all elements, except internal table elements when
border-collapseiscollapse - 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-widthis0, a unitless width becomes0too and nothing is drawn. - No layout effect. Only
border-widthand 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.
Related
border-imageโ the shorthandborder-image-source,border-image-slice,border-image-outset,border-image-repeatborder-width- Lesson: Border Images