Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
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-sourceproperty must be used withborder-image-sliceto work properly - Set
bordertotransparentto ensure the image border displays correctly - Use
border-image-repeatto 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.
Advertisements
