Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Borders, Outlines and Shadows

The border-image-repeat property

Reference for the CSS border-image-repeat property: choose whether edge pieces of a border image stretch, repeat, round or space out, with a live example.

The border-image-repeat property controls how the four edge pieces of a sliced border image fill the sides of the box. The corner pieces are never repeated; only the edges are affected. Pick one keyword for both axes, or two keywords: the first applies to the horizontal edges (top and bottom), the second to the vertical edges (left and right).

CSS
.frame {
  border-image-repeat: round;
}

Try it

Four repeat modes

Look at the dark tick in the middle of each edge. With stretch there is one long tick, repeat may cut a tick at the end, round squeezes whole ticks to fit, and space leaves gaps between whole ticks.

Syntax

CSS
border-image-repeat: [ stretch | repeat | round | space ]{1,2};
  • Initial value: stretch
  • Applies to: all elements, except internal table elements when border-collapse is collapse
  • Inherited: no
  • Animatable: no (discrete)
  • Computed value: two keywords, horizontal then vertical

Values

Value Description
stretch The edge piece is scaled to fill the whole side.
repeat The edge piece is tiled at its natural size, centered, and the tiles at both ends may be cut off.
round The piece is tiled, but the number of tiles is rounded and each tile is scaled so that whole tiles fill the side exactly.
space The piece is tiled at natural size, but only as many whole tiles as fit; leftover space is spread evenly between them.
Two keywords First for the top and bottom edges, second for the left and right edges.

Usage notes

  • Choose round for dashes. For custom dashed borders, round avoids clipped dashes, with a small stretch in the dash size.
  • space hides the pattern if tiles do not fit. If not even one tile fits, nothing is drawn on that edge.
  • Corners are fixed. They are never repeated or stretched in this property.
  • repeat can look uneven, because partial tiles appear at both ends of each side.
  • Gradients. For a gradient source stretch is almost always what you want.

Browser support

Supported in every current browser, without prefixes.