bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/CSS/Advanced Styling
CSS•Advanced Styling

CSS Border Images

With the CSS border-image property, you can define an image to be used as the border around an element.

CSS border-image Property

The border-image property allows you to define an image to be used as the border around an element, instead of the normal border.

This property takes an image and slices it into nine sections, like a tic-tac-toe board. It then places the corners at the corners, and the middle sections are repeated or stretched as you specify.

The border-image property is a shorthand property for the following properties:

  • border-image-source - defines the path to the image
  • border-image-slice - defines how to slice the image
  • border-image-width - defines the width of the image
  • border-image-outset defines the amount by which the border image area extends beyond the border box
  • border-image-repeat - defines how to repeat the image

Note

For border-image to work, the element also needs the border property set!

CSS border-image - Different Slice Values

Different slice values completely changes the look of the border image:

Example

Formatted code
#borderimg1 {
  border: 10px solid transparent;
  padding: 15px;
  border-image: url(border.png)
  50 round;
}
#borderimg2 {
  border: 10px solid transparent;
  padding: 15px;
  border-image: url(border.png) 20% round;
}
#borderimg3 {
  border: 10px solid transparent;
  padding: 15px;
  border-image: url(border.png)
  30% round;
}

Live preview

CSS Border Image Properties

PropertyDescription
border-imageA shorthand property for setting all the border-image-* properties
border-image-sourceSpecifies the path to the image to be used as a border
border-image-sliceSpecifies how to slice the border image
border-image-widthSpecifies the widths of the border image
border-image-outsetSpecifies the amount by which the border image area extends beyond the border box
border-image-repeatSpecifies whether the border image should be repeated, rounded or stretched

Previous

Sass Tutorial

Next

CSS Multiple Backgrounds

This chapter

Overview
53

Lessons

154m

Read time

1. CSS Rounded Corners2. Sass Tutorial3. CSS Border Images4. CSS Multiple Backgrounds5. CSS Background Size6. CSS Background Origin7. CSS Background Clip8. CSS Colors9. CSS Color Keywords10. CSS Gradients11. CSS Radial Gradients12. CSS Conic Gradients13. CSS Shadow Effects14. CSS Box Shadow15. CSS Text Effects16. CSS Custom Fonts17. CSS 2D Transforms18. CSS 2D Transform Scale19. CSS 2D Transform Skew / Matrix20. CSS 3D Transforms21. CSS Transitions22. CSS Transition Timing23. CSS Animations24. CSS Animation Timing25. CSS Animation Properties26. CSS Tooltip27. CSS Tooltip Arrows28. CSS Styling Images29. CSS Image Effects30. CSS Image Hover Overlays31. CSS Responsive Modal Images32. CSS Centering Images33. CSS Image Filter Effects34. CSS Image Shapes35. CSS object-fit Property36. CSS object-position Property37. CSS Masking38. CSS Gradient Mask Layers39. CSS SVG Mask Layers40. CSS Styling Buttons41. CSS Button Hover Effects42. CSS Button Groups43. CSS Pagination Styles44. CSS Multiple Columns45. CSS Column Rules46. CSS User Interface47. CSS Variables - var() Function48. CSS Overriding Variables49. CSS Variables and JavaScript50. CSS Variables in Media Queries51. CSS @property Rule52. CSS Box Sizing53. CSS Media Queries

On this page

CSS border-image PropertyCSS border-image - Different Slice ValuesCSS Border Image Properties