border-image-source
Definition
The border-image-source property in CSS specifies the image to use for the border of an element. It is used in conjunction with the border-image-slice property, which specifies how the image should be sliced into pieces to form the border, and the border-image-repeat property, which specifies how the image should be repeated or stretched to fill the border area.
Examples
Use the image 'my-border-image.png' as the border image:
border-image-source: url('my-border-image.png');
Use the image 'my-gradient.png' as the border image:
border-image-source: url('my-gradient.png');
Use the image 'my-pattern.png' as the border image:
border-image-source: url('my-pattern.png');
Values
The border-image-source property takes a single value, which should be a URL pointing to the image to use for the border.
Best Practices
- Use the
border-image-sourceproperty to specify the image to use for the border of an element. The image is sliced into pieces using theborder-image-sliceproperty, and the pieces are placed along the edges of the element. The remaining area is filled with the image, as specified by theborder-image-repeatproperty. - Specify the URL of the image using a relative or absolute path. For example:
border-image-source: url('images/my-border-image.png');orborder-image-source: url('https://example.com/images/my-border-image.png'); - Use the
border-image-sourceproperty in conjunction with theborder-image-sliceproperty, which specifies how the image should be sliced into pieces to form the border, and theborder-image-repeatproperty, which specifies how the image should be repeated or stretched to fill the border area. - If you want to create a border with a solid color or gradient, you can use a 1x1 pixel image as the border image and use the
border-image-sliceproperty to slice it into pieces that form the border. - If you're using a small image or pattern as the border image, you may want to use the
repeatvalue for theborder-image-repeatproperty to tile the image to fill the border area. - If you're using a large image as the border image, you may want to use the
stretchvalue for theborder-image-repeatproperty to ensure that the image fills the entire border area. - Keep in mind that the
border-image-sourceproperty only works when used with theborder-image-sliceproperty, which specifies how the image should be sliced into pieces to form the border, and theborder-image-repeatproperty, which specifies how the image should be repeated or stretched to fill the border area.
Browser Compatibility
| Chrome | Firefox | Safari | Internet Explorer | Microsoft Edge | Opera |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
Note that support for the border-image-source property is limited in Internet Explorer 10 and earlier.