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).
.frame { border-image-repeat: round; }
Try it
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
border-image-repeat: [ stretch | repeat | round | space ]{1,2};
- Initial value:
stretch - Applies to: all elements, except internal table elements when
border-collapseiscollapse - 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
roundfor dashes. For custom dashed borders,roundavoids clipped dashes, with a small stretch in the dash size. spacehides 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.
repeatcan look uneven, because partial tiles appear at both ends of each side.- Gradients. For a gradient source
stretchis almost always what you want.
Browser support
Supported in every current browser, without prefixes.
Related
border-imageโ the shorthandborder-image-source,border-image-slice,border-image-width,border-image-outset- Lesson: Border Images