CSS border-image-repeat Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Box Model & Layout

What You’ll Learn

The border-image-repeat property controls how border image edge slices are drawn along each side — stretched, tiled, rounded to fit, or spaced evenly.

01

Edge Tiling

How sides repeat.

02

stretch

Default keyword.

03

repeat

Tile the image.

04

round

Fit tiles evenly.

05

space

Add gap spacing.

06

border-image

Longhand property.

Definition and Usage

The border-image-repeat CSS property defines how the middle sections of a border image are repeated along the top, right, bottom, and left edges of an element. Corner slices stay fixed; this property affects only the edge regions between corners.

It is especially useful for decorative borders built from images or repeating patterns. Choosing the right keyword helps edges look smooth, evenly tiled, or intentionally stretched depending on your design.

💡
Beginner Tip

Start with round when using tiled border artwork — it scales tiles to fit each side cleanly. Use stretch when you want one continuous edge image.

📝 Syntax

border-image-repeat accepts one or two keyword values:

syntax.css
selector {
  border-image-repeat: stretch | repeat | round | space;
}

/* horizontal | vertical */
selector {
  border-image-repeat: round repeat;
}

Basic Example

border-image-repeat.css
.border-box {
  width: 300px;
  height: 150px;
  border: 10px solid transparent;
  border-image-source: url("border-image.png");
  border-image-slice: 30;
  border-image-repeat: round;
}

Syntax Rules

  • One keyword applies the same behavior to all four edges.
  • Two keywords set horizontal edges first, then vertical edges.
  • Valid keywords are stretch, repeat, round, and space.
  • Requires a border image source and slice to be visible.
  • Can also be set through the border-image shorthand.

⚡ Quick Reference

QuestionAnswer
Initial valuestretch
Applies toBorder image edge regions
InheritedNo
AnimatableNo
Common useDecorative tiled or stretched image borders

Default Value

The default value of border-image-repeat is stretch. That means edge slices are scaled to fill the full length of each border side unless you choose another keyword.

💎 Property Values

KeywordExampleMeaning
stretchborder-image-repeat: stretch;Stretches edge slices to fill the border side
repeatborder-image-repeat: repeat;Repeats edge tiles; may clip partial tiles
roundborder-image-repeat: round;Repeats tiles and scales them to fit evenly
spaceborder-image-repeat: space;Repeats tiles with extra space distributed between them

Keyword Previews

stretchScales to fill
repeatTiles as-is
roundScales tiles to fit
spaceSpaces between tiles

border-image-repeat vs related properties

PropertyTargetsBest for
border-image-repeatHow edge slices tile or stretchControlling border edge appearance
border-image-sliceHow the source image is dividedCutting corners and edges from artwork
border-image-sourceThe image or gradient usedChoosing the border artwork
border-imageFull border image shorthandSetting source, slice, width, outset, and repeat together

👀 Live Preview

A box with a repeating pattern border using round:

Content inside the border.

Uses a repeating gradient source with border-image-repeat: round;.

Examples Gallery

Try border-image-repeat with round, stretch, repeat, space, and two-value syntax.

📚 Basic Repeat Keywords

Apply border image longhands and choose how edge slices are repeated.

Example 1 — Round Border Image Repeat

Apply a border image to a div and use round so tiles scale to fit each edge, as in the reference tutorial.

border-image-repeat-round.html
<style>
  .border-box {
    width: 260px;
    height: 100px;
    padding: 0.75rem;
    border: 10px solid transparent;
    border-image: repeating-linear-gradient(45deg, #059669 0 10px, #fff 10px 20px) 10 round;
    background: #fff;
  }
</style>

<div class="border-box">
  Content inside the border.
</div>
Try It Yourself

How It Works

With round, the browser repeats edge tiles and adjusts their size so they fit the border length without awkward partial clips.

Example 2 — Stretch (Default Behavior)

Use stretch to scale edge slices across the full length of each side.

border-image-repeat-stretch.css
.frame {
  border: 8px solid transparent;
  border-image: repeating-linear-gradient(45deg, #2563eb 0 8px, #fff 8px 16px) 8 stretch;
  padding: 1rem;
  background: #fff;
}
Try It Yourself

How It Works

stretch is the default. Edge artwork is scaled to cover the entire side, which can distort repeating patterns but works well for smooth gradients.

🎨 More Repeat Modes

Compare plain tiling with spaced tiles and mixed horizontal or vertical behavior.

Example 3 — Repeat and Space

Tile edge slices with repeat, or distribute gaps evenly with space.

border-image-repeat-space.css
.tile-border {
  border: 8px solid transparent;
  border-image: repeating-linear-gradient(90deg, #dc2626 0 12px, #fff 12px 24px) 8 space;
  width: 16rem;
  height: 5rem;
  background: #fff;
}
Try It Yourself

How It Works

space repeats tiles and adds equal gaps between them so the pattern fits the border length cleanly.

Example 4 — Different Repeat on Horizontal and Vertical Edges

Use two keywords so top/bottom edges behave differently from left/right edges.

border-image-repeat-dual.css
.panel {
  border: 8px solid transparent;
  border-image-source: repeating-linear-gradient(45deg, #7c3aed 0 8px, #fff 8px 16px);
  border-image-slice: 8;
  border-image-repeat: round stretch;
  padding: 1rem;
  background: #fff;
}
Try It Yourself

How It Works

The first keyword applies to top and bottom edges; the second applies to left and right edges. This gives finer control over asymmetric frames.

🧠 How border-image-repeat Works

1

The image is sliced

border-image-slice divides the source into corners and edge strips.

Slice
2

You choose a repeat keyword

Set stretch, repeat, round, or space.

CSS rule
3

Edge strips fill each side

The browser tiles or scales the middle edge regions along each border.

Rendering
=

Decorative edge pattern

Your border edges look tiled, stretched, or evenly spaced based on the keyword you chose.

Modern Browser Support

The border-image-repeat property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera.

Baseline · Modern browsers

Border image repeat in today’s browsers

Chrome, Edge, Firefox, Safari, and Opera support all four repeat keywords 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
border-image-repeat property 96% supported

Bottom line: Use border-image-repeat freely in modern projects. Test tiled artwork with both wide and narrow elements.

Conclusion

The border-image-repeat property gives you flexible control over how border image edges are drawn. Whether you need stretched gradients, tiled patterns, evenly rounded tiles, or spaced repeats, the right keyword makes decorative borders look polished.

Experiment with stretch, repeat, round, and space to see how each one changes the look of your border edges.

💡 Best Practices

✅ Do

  • Use round for tiled border artwork on variable-width elements
  • Use stretch for smooth gradients or single-piece edge images
  • Test repeat behavior at different box sizes
  • Combine longhands when learning slice and repeat separately
  • Preview all four keywords before picking one for production

❌ Don’t

  • Expect repeat keywords to affect corner slices
  • Use repeat on small boxes if partial tile clipping looks bad
  • Forget to set border-image-source and border-image-slice
  • Assume round and space look identical on every browser
  • Rely on image borders alone for critical focus or accessibility cues

Key Takeaways

Knowledge Unlocked

Five things to remember about border-image-repeat

Use these points when tiling border image edges.

5
Core concepts
02

Default stretch

Scales to fit.

Default
🔀03

Four Keywords

stretch repeat round space.

Values
↔️04

Two Values

Horizontal | vertical.

Syntax
🛠05

Needs slice

Part of border-image.

Usage

❓ Frequently Asked Questions

The border-image-repeat property controls how the middle sections of a border image are drawn on each edge — whether they stretch, tile, round, or space to fit the border length.
The initial value is stretch, which scales the edge slices to fill the full length of each border side.
repeat tiles the edge image as-is and may clip partial tiles. round also tiles the image but scales the tiles so they fit evenly without clipping.
Yes. With two values, the first applies to the top and bottom edges and the second applies to the left and right edges.
No. border-image-repeat only affects how edge regions are painted when a border image source and slice are already applied.

Practice in the Live Editor

Open the HTML editor, try border-image-repeat, and preview tiled border edges instantly.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful