
- CSS - Home
- CSS - Roadmap
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Types
- CSS - Measurement Units
- CSS - Selectors
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS - Cascading
- CSS - Universal Selectors
- CSS - ID Selectors
- CSS - Group Selectors
- CSS - Class Selectors
- CSS - Child Selectors
- CSS - Element Selectors
- CSS - Descendant Selectors
- CSS - General Sibling Selectors
- CSS - Adjacent Sibling Selectors
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Advanced Features
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS Interview Questions
- CSS Online Quiz
- CSS Online Test
- CSS Mock Test
- CSS - Quick Guide
- CSS - Cheatsheet
- CSS - Properties References
- CSS - Functions References
- CSS - Color References
- CSS - Web Browser References
- CSS - Web Safe Fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS - border-image Property
CSS border-image property allows you to use an image as the border of an element. It is a shorthand property for defining values to the properties border-image-source, border-image-slice, border-image-width, border-image-outset and border-image-repeat.
Syntax
border-image: source slice width outset repeat | initial | inherit;
Property Values
Value | Description |
---|---|
border-image-source | It specifies the path of the image to be used as border. |
border-image-slice | It specifies how the image is to be sliced. |
border-image-width | It specifies the width of the specified image. |
border-image-outset | It specifies the amount by which the border image is to be extended beyond the border box. |
border-image-repeat | It specifies whether the image is to be rounded, strecthed or repeated. |
initial | This sets the property to its default value. |
inherit | This inherits the property from the parent element. |
Examples of CSS Border Image Property
The following examples explain the border-image property with different values.
Defining All Values of Border Image Property
The border-image property is a shorthand property for setting the values to image's source, slice, width, outset and repeat. In the following example, the values for the properties have been declared in one declaration.
Example
<!DOCTYPE html> <html> <head> <style> .size { height: 200px; width: 300px; margin: 20px; border: 20px solid transparent; } .border-image-example1 { border-image: url(/https/www.tutorialspoint.com/css/images/white-flower.jpg) 50 round; } .border-image-example2 { border-image: url(/https/www.tutorialspoint.com/css/images/white-flower.jpg) 10 20 30 40 round; } </style> </head> <body> <h2> CSS border-image property </h2> <div class="border-image-example1 size"> This border has been set using border-image with same slice value 50 for all sides. </div> <div class="border-image-example2 size"> This border has been set using border-image with separate slice values 10 20 30 40 for all sides. </div> <p> Image used: </p> <img src="/https/www.tutorialspoint.com/css/images/white-flower.jpg" alt="flower" height=150> </body> </html>
Constitutent Properties of Border Image Property
The border-image property combines border-image-source, border-image-slice, border-image-width, border-image-outset, and border-image-repeat. The following example demonstrate how these properties work together to create the border image effect.
Example
<!DOCTYPE html> <html> <head> <style> .size { height: 150px; width: 200px; margin:60px; border: 30px solid transparent; } .border-image-example1 { border-image-source: url(/https/www.tutorialspoint.com/css/images/white-flower.jpg); border-image-slice: 70; border-image-width: 15px; border-image-outset: 25px; border-image-repeat: repeat; } .border-image-example2 { border-image-source: url(/https/www.tutorialspoint.com/css/images/white-flower.jpg); border-image-slice: 20 40 60 80; border-image-width: 17px; border-image-outset: 15px; border-image-repeat: stretch; } </style> </head> <body> <h2> CSS border-image property </h2> <div class="outer-box"> <div class="border-image-example1 size"> This border has been set using consitutent properties of border-image with 70 slice, 25px width, 35px outset and repeat repeat. </div> </div> <div class="outer-box"> <div class="border-image-example2 size"> This border has been set using consitutent properties of border-image with 20,40,60,80 slice, 17px width,15px outset and repeat stretch. </div> </div> <p> Image used: </p> <img src="/https/www.tutorialspoint.com/css/images/white-flower.jpg" alt="flower" height=150> </body> </html>
Border Image Property with Gradient
CSS gradients can also be used to set the border of an element. There are three types of gradients supported: linear, radial and conic. These are shown in the following example.
Example
<!DOCTYPE html> <html> <head> <style> img { height: 200px; width: 200px; margin: 20px; border-style: solid; border-width: 10px; } img.linear-gradient { border-image: linear-gradient(45deg, rgb(15, 64, 161), rgb(228, 6, 17)) 1; } img.radial-gradient { border-image: radial-gradient(rgb(58, 61, 60), rgb(47, 227, 221)) 1; } img.conic-gradient { border-image: conic-gradient(red, yellow, green, aqua, blue) 1; } </style> </head> <body> <h2> CSS border-image property </h2> <div> <p> a) Linear Gradient </p> <img class="linear-gradient" src="/https/www.tutorialspoint.com/css/images/white-flower.jpg" alt="linear-gradient" /> </div> <div> <p> b) Radial Gradient </p> <img class="radial-gradient" src="/https/www.tutorialspoint.com/css/images/white-flower.jpg" alt="radial-gradient" /> </div> <div> <p> b) Conic Gradient </p> <img class="conic-gradient" src="/https/www.tutorialspoint.com/css/images/white-flower.jpg" alt="conic-gradient" /> </div> </body> </html>
Supported Browsers
Property | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
border-image | 16.0 | 11.0 | 15.0 | 6.0 | 15.0 |