The border-image property uses an image or gradient as a border. CSS slices the source into corners and edges, then stretches or repeats those pieces around your element.
01
Image Borders
Beyond solid lines.
02
Shorthand
Source, slice, repeat.
03
Slice Values
Divide the image.
04
Repeat Modes
stretch, round, space.
05
Gradients
No file required.
06
Longhands
Five sub-properties.
Fundamentals
Definition and Usage
The border-image CSS property is a shorthand for drawing borders with an image or gradient instead of a basic line style. The browser slices the source image into nine regions — four corners, four edges, and a center — then places those regions around the element’s border box.
This property is useful for decorative frames, themed cards, buttons, and UI elements that need richer borders than solid, dashed, or dotted can provide.
💡
Beginner Tip
Start with a transparent border width, then add border-image. Example: border: 10px solid transparent; and border-image: linear-gradient(...) 1;.
Foundation
📝 Syntax
border-image combines source, slice, width, outset, and repeat in one declaration:
The transparent border creates space for the image. The slice value 30 cuts the image 30 pixels from each edge, and round scales edge tiles to fit cleanly.
Example 2 — Gradient Border Without an Image File
Use a CSS gradient as the border source — no external image required.
Padding keeps content away from the decorative border. The gradient frame adds visual emphasis without extra HTML elements.
🧠 How border-image Works
1
You set a border width
The element needs border space — often border: 10px solid transparent;.
Border area
2
The source is sliced into nine parts
CSS cuts the image or gradient into corners, edges, and a center region.
Slice
3
Edge pieces fill each side
Corners stay fixed while edges stretch or repeat based on your keyword.
Repeat
=
🖼️
Custom image border
Your element gets a decorative frame that goes beyond basic line styles.
Compatibility
Modern Browser Support
The border-image property is supported in all modern browsers. Gradient sources work in current Chrome, Firefox, Safari, and Edge versions.
✓ Baseline · Modern browsers
Image borders in today’s browsers
Chrome, Edge, Firefox, Safari, and Opera support border-image in current versions.
96%Modern browser support
Google Chrome15+ · Desktop & Mobile
Full support
Mozilla Firefox15+ · Desktop & Mobile
Full support
Apple Safari6+ · macOS & iOS
Full support
Microsoft Edge12+ · All versions
Full support
Opera15+ · Modern versions
Full support
Fallback behavior
When unsupported, the border falls back to normal border styling.
💻
Internet ExplorerPartial support in IE 11 · May need vendor prefixes for older versions
Partial
border-image property96% supported
Bottom line: Use border-image for decorative borders in modern projects. Provide a simple solid border fallback for legacy browsers if needed.
Wrap Up
Conclusion
The border-image property opens up creative border styling beyond plain lines. By combining a source image or gradient with slice and repeat values, you can build frames, patterned edges, and eye-catching UI elements.
Experiment with different sources, slice numbers, and repeat keywords to see how this property can enhance the visual appeal of your web designs.
Set a visible border width before applying border-image
Use gradients for simple colorful borders without image files
Test slice values with your actual border artwork
Keep border width proportional to the design
Provide a solid border fallback for critical UI elements
❌ Don’t
Forget that border-radius and border-image interact inconsistently across browsers
Use huge slice values without checking the source image size
Depend on image borders for essential accessibility cues alone
Assume round and repeat behave identically on all sides
Skip testing on mobile browsers for gradient borders
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about border-image
Use these points when building decorative borders.
5
Core concepts
🖼️01
Image Borders
Uses sliced sources.
Purpose
⚡02
Default none
Normal borders.
Default
✂️03
Slice
Nine-region cut.
Syntax
🔀04
Repeat
stretch, round, space.
Behavior
🎨05
Gradients
No file needed.
Tip
❓ Frequently Asked Questions
The border-image property lets you use an image or gradient as an element's border instead of a plain solid line. It slices the source into regions and maps them to the border edges and corners.
The initial value is none, which means no image border is used and the element falls back to normal border properties.
You usually need a visible border width, a border-image-source, and a border-image-slice value. A common pattern is border: 10px solid transparent; followed by border-image settings.
Yes. Gradients work as a border-image-source in modern browsers and are a simple way to create colorful borders without an image file.
border sets width, style, and color for standard lines. border-image replaces the border painting with a sliced image or gradient while still using the border area for sizing.