CSS border-image-source
Property
The border-image-source
property in CSS defines the image to be used as a border around an element. This image replaces the normal CSS border.
1. Syntax
✅ This property works only if a border
is set on the element.
2. Accepted Values
Value | Description | Example |
---|---|---|
none | No border image (default) | border-image-source: none; |
url("image.png") | Specifies an image file | border-image-source: url("border.png"); |
linear-gradient(...) | Uses a gradient as a border | border-image-source: linear-gradient(to right, red, blue); |
3. Example – Using an Image as a Border
✅ The border.png
image is used as a border.
4. Example – Using a Gradient as a Border
✅ The border is a gradient from red to blue.
5. Example – No Border Image (Default)
✅ Falls back to the normal CSS border
style.
6. Using border-image
Shorthand
Instead of setting border-image-source
separately, use the shorthand:
✅ This is equivalent to:
7. Best Practices
✔ Ensure border
is set, or border-image-source
won’t work.
✔ Use border-image-slice
to control how the image is divided.
✔ Use border-image-source: none;
to remove a border image and fall back to normal borders.