Set the image path with CSS

The CSS border-image-source property is used to set the path of an image that will be used as a border around an element. This property allows you to replace traditional solid borders with custom images for more creative styling.

Syntax

selector {
    border-image-source: url(path-to-image) | none;
}

Possible Values

Value Description
url() Specifies the path to the image file
none No image is used (default value)

Example: Setting Image Border Path

The following example demonstrates how to set an image path for creating a decorative border −

<!DOCTYPE html>
<html>
<head>
<style>
    .image-border {
        border: 15px solid transparent;
        padding: 20px;
        width: 300px;
        border-image-source: url(/css/images/border.png);
        border-image-slice: 30;
        border-image-repeat: round;
        text-align: center;
        background-color: #f9f9f9;
    }
</style>
</head>
<body>
    <div class="image-border">
        <p>This element has a custom image border created using border-image-source property.</p>
    </div>
</body>
</html>
A box with a decorative image border appears on the page. The border uses the specified image pattern, and the text is centered within the bordered area.

Key Points

  • The border-image-source property must be used with border-image-slice to work properly
  • Set border to transparent to ensure the image border displays correctly
  • Use border-image-repeat to control how the image fills the border area
  • The image path can be relative or absolute URL

Conclusion

The border-image-source property enables you to create visually appealing borders using custom images. Remember to combine it with related border-image properties for complete control over the border appearance.

Updated on: 2026-03-15T11:57:49+05:30

775 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements