Home CSS Properties border-image CSS border-image Property Definition
Definition and Usage The border-image property is a shorthand that paints an image or gradient around an element. It replaces the usual solid border look with sliced regions from a source.
It sets border-image-source , border-image-slice , border-image-width , border-image-outset , and border-image-repeat . Keep a normal border-style and width as a fallback — some browsers skip the image when style is none or width is 0. It is not inherited.
Standard-track. Not deprecated and not experimental. The shorthand is Baseline and widely available. Always set a fallback border style in case the image fails to load.
Syntax
CSS Syntax border-image: <source> <slice> [ / <width> ]? [ / <outset> ]? <repeat>? | initial | inherit ;
A minimal useful form is source + slice, for example linear-gradient(...) 1. Width and outset use / separators.
Values
Property Values Part Description Try it sourceImage URL or gradient. Default is none Try itsliceHow far into the source to cut corners and edges Try it/ widthOptional width of the painted border image area Try itrepeatstretch (default), repeat, round, or space Try itinitialResets all longhands to their defaults Try itinheritTakes the parent’s border-image Try it
Approach
How to Use border-image Give the box a border area, then replace the paint with an image or gradient.
Set a visible border first, for example border: 20px solid. Choose a source (URL or gradient). Add a slice so the browser knows how to cut the source. Optionally add / width, a second / outset, and a repeat keyword such as round. Piece Required? Role Border width + style Yes (in practice) Creates the border area; fallback if the image fails Source Yes What to paint: image or gradient Slice Yes Cuts the source into corners and edges Repeat / width / outset Optional Fit the slices and size the painted frame
Try it
Live Preview The box already has a solid border width. Switch shorthand presets to see gradient and stripe frames.
Code
CSS Examples Each snippet keeps CSS lean: a border area, then border-image. Use Try It Yourself for a live editor.
1. Gradient 2. Round 3. Image file Example 1 — Gradient Border Use a gradient as the source with a simple slice of 1.
<style>
p {
border: 20px solid;
border-image: linear-gradient(135deg, #2563eb, #dc2626) 1;
}
</style>
<p>Gradient border</p> How It Works Create a border area. border: 20px solid sets width and style so the frame has space to paint.Choose a source. linear-gradient(...) is the image to slice.Slice once. 1 cuts a thin region from the gradient — enough for a simple colored frame.Fallback stays ready. If the gradient somehow fails, the solid border style remains.Example 2 — Width and Round Add an explicit image width and round so edge tiles fit evenly.
<style>
p {
border: 20px solid;
border-image: linear-gradient(135deg, #2563eb, #0f766e) 1 / 20px round;
}
</style>
<p>Rounded fit</p> How It Works Keep source + slice. The gradient and 1 still define what to paint.Add width after a slash. / 20px sets the border-image width to match the border area.Use round. round scales edge pieces so they fit without clipping or awkward gaps.Compare with stretch. The default stretch pulls one piece to fill each edge instead.Example 3 — Image File Slice a bitmap and map the pieces around the box.
<style>
p {
border: 30px solid;
border-image: url("/images/apple.png") 30 / 30px round;
}
</style>
<p>Image border</p> How It Works Point to a file. url("/images/apple.png") is the source bitmap.Pick a slice. 30 means cut 30 CSS pixels inward from each edge of the image.Size the paint. / 30px makes the painted border 30px thick.Fit the edges. round adjusts how many edge tiles fit along each side. Edge Cases & Pitfalls If the image border is missing or looks wrong, check these first.
fallback Need width and style Some browsers will not paint border-image when border-style is none or width is 0. Set a solid border first.
reset border resets the shorthandA later border declaration resets all border-image-* longhands. Put border-image after border.
radius border-radius does not clip itborder-radius has no effect on border images. Round the artwork itself, or use layered backgrounds for curved gradient frames.
a11y Not read by assistive tech Screen readers cannot parse border images. If the image carries meaning, put that meaning in real text in the document.
Compatibility
Browser Support border-image is a browser CSS property for element borders. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
border-image Chrome 56+, Firefox 50+, Safari 9.1+, Edge 12+, Internet Explorer 11. Gradients as sources are widely supported in modern browsers.
Google Chrome 56+
Full support
Mozilla Firefox 50+
Full support
Apple Safari 9.1+
Full support
Microsoft Edge 12+
Full support
Opera 43+
Full support
Samsung Internet 7.2+
Full support
Internet Explorer 11
Full support border-image Widely supported
Bottom line: Safe for modern browsers. Always keep a normal border style as fallback, and remember that Internet Explorer before 11 has no support.
Remember
Key Takeaways Role: shorthand that paints a sliced image or gradient as the border.
Needs a border area: set width and style first, then border-image.
Parts: source, slice, optional / width, optional / outset, optional repeat.
Limits: border-radius does not round it, and border can reset it.
One line: border-image replaces the border paint with a sliced source — after you give the box a real border area to paint into.
Frequently Asked Questions What does the CSS border-image property do? It is a shorthand that draws an image or gradient around an element instead of a plain border line. It sets source, slice, width, outset, and repeat together.
Why is my border-image not showing? Many browsers need a visible border width and a non-none border-style. A common pattern is border: 20px solid; then set border-image. If the source is none or fails to load, the normal border style shows instead.
Can I use a gradient with border-image? Yes. A linear-gradient or repeating-linear-gradient can be the source. Pair it with a slice value such as 1 for a simple gradient frame.
Does border-radius clip border-image? No. border-radius does not round a border image. Bake the curve into the image, or use a dual-background trick if you need rounded gradient frames.
Does the border shorthand reset border-image? Yes. Setting border resets the border-image longhands to their initial values. Apply border-image after border, or avoid resetting it.
Which browsers support border-image? It is Baseline and widely available: Chrome 56+, Firefox 50+, Safari 9.1+, Edge 12+, and Internet Explorer 11. It is a browser style property, not a Node.js feature.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion