CSS Reference ยท Borders, Outlines and Shadows
The border-image-source property
Reference for the CSS border-image-source property: choose the image, SVG or gradient that is painted in the border area, with live examples and usage notes.
The border-image-source property chooses which image is painted in the border area of a box. It accepts anything that counts as a CSS image: a url() pointing to a PNG, JPEG or SVG, an inline data: URL, or a gradient function. The keyword none means "no border image", so the normal border style is used.
Setting the source alone is not enough to see a nice result: the image is cut up using border-image-slice, whose default is 100%. With 100% the corners take the whole image and the edges are empty, so you usually set a slice too, or use the border-image shorthand.
.box { border: 8px solid; border-image-source: linear-gradient(to right, #0ea5e9, #22c55e); border-image-slice: 1; }
Try it
Syntax
border-image-source: none | <image>;
- Initial value:
none - Applies to: all elements, except internal table elements when
border-collapseiscollapse - Inherited: no
- Animatable: no (discrete)
- Computed value:
none, or the image with any URL made absolute
Values
| Value | Description |
|---|---|
none |
No border image. The border is drawn with its border-style and color. |
url(...) |
A raster or vector image file. SVG files should have a size or a viewBox so slices make sense. |
linear-gradient(), radial-gradient(), conic-gradient() and repeating forms |
A generated image. |
image-set() |
A set of resolution alternatives chosen by the browser. |
Usage notes
- If the image fails to load, the browser falls back to the regular border, so keep a sensible
border-styleand color. - Gradients have no intrinsic size. Use a numeric slice such as
1; percentages refer to the image size, which a gradient gets from the border image area. - Cross-fading is not supported. Switching the source on hover is instant. Animate a custom property inside a gradient with
@propertyinstead. - Data URLs. Inline SVG works, but
#must be written%23and quotes need care. External files are easier to maintain. - Not clipped by
border-radius. The image is drawn square regardless of rounded corners.
Browser support
Supported in every current browser.
Related
border-imageโ the shorthandborder-image-slice,border-image-width,border-image-outset,border-image-repeat- Lesson: Border Images
- Lesson: Gradients