CSS border-image-repeat Property

CSS border-image-repeat property specifies how the sliced images should be tiled and scaled so that they can fill the middle section and the sides of the border. In order to fill the middle section and sides of the border, the sliced images can repeat or stretch.

In the example below, the sliced images repeat to fill the sides of the border. Try it out:

Example:

div{
  border-image-source: url(images/border-diamonds.png);
  border-image-repeat: repeat;
}

If we don’t want the sliced image to be repeated, we can use border-image-repeat: stretch;. In this case, the sliced images stretch to cover the full length of the border. Refer to the example below:

Example:

div{
  border-image-source: url(images/border-diamonds.png);
  border-image-repeat: stretch;
}

CSS Syntax

The border-image-repeat property has the below syntax:

border-image-repeat: stretch|repeat|round|space|initial|inherit;

Property Values

The border-image-repeat property accepts the following values:

stretchThis is the default value. The sliced images stretch to cover the full length of the border.
repeatThe sliced images repeat to cover the full length of the border.
roundSimilar to repeat. The only difference is that the sliced images are rescaled if they do not fill the border with a whole number.
spaceIt is also similar to repeat. The only difference is that, if the sliced images do not fill the area with a whole number, the remaining space is evenly distributed among the repeated tiles.
initialSets the border-image-repeat property to its default value(stretch).
inheritInherits the border-image-repeat property from the parent element.

General Info

Default Valuestretch
InheritedNo
JavaScript Usageelement.style.borderImageRepeat = “repeat”;

Related Pages

CSS Tutorial: CSS Borders

Author

  • Manoj Kumar

    Hi, My name is Manoj Kumar. I am a full-stack developer with a passion for creating robust and efficient web applications. I have hands-on experience with a diverse set of technologies, including but not limited to HTML, CSS, JavaScript, TypeScript, Angular, Node.js, Express, React, and MongoDB.

Leave a Comment