background-repeat property CSS Reference



Definition and Usage

The background-repeat CSS property defines how background images are repeated. A background image can be repeated along the horizontal axis, the vertical axis, both, or not repeated at all. When the repetition of the image tiles doesn't let them exactly cover the background, the way adjustments are done can be controlled by the author: by default, the last image is clipped, but the different tiles can instead be re-sized, or space can be inserted between the tiles.

Note: If the value of this property is not set in a background shorthand property that is applied to the element after the background-repeat CSS property, the value of this property is then reset to its initial value by the shorthand property.

  • Initial repeat
  • Applies to all elements
  • Inherited no
  • Media visual
  • Computed Value a list, each item consisting of two keywords, one per dimension
  • Animatable no
  • Canonical order the unique non-ambiguous order defined by the formal grammar

Syntax

Formal syntax: <repeat-style>#
background-repeat: repeat-x     /* One-value syntax */
background-repeat: repeat-y
background-repeat: repeat
background-repeat: space
background-repeat: round
background-repeat: no-repeat
background-repeat: repeat space   /* Two-value syntax */
background-repeat: repeat repeat
background-repeat: round space
background-repeat: no-repeat round
background-repeat: inherit

Values

<repeat-style>
Is following either the one-value syntax - and in that case the values are shorthand for ther two-value equivalent:
repeat-xis the equivalent of repeat no-repeat
repeat-yis the equivalent of no-repeat repeat
repeatis the equivalent of repeat repeat
spaceis the equivalent of space space
roundis the equivalent of round round
no-repeatis the equivalent of no-repeat no-repeat
Or the two-value syntax where the first value represents the horizontal behavior of the repetition and the second value the vertical behavior:
repeatThe image is repeated in the given direction as much as needed to cover the whole background image painting area. The last image may be clipped if the whole thing won't fit in the remaining area.
spaceThe image is repeated in the given direction as much as needed to cover most of the background image painting area, without clipping an image. The remaining non-covered space is spaced out evenly between the images. The first and last images touches the edge of the element. The value of the background-position CSS property is ignored for the concerned direction, except if one single image is greater than the background image painting area, which is the only case where an image can be clipped when the space value is used.
roundThe image is repeated in the given direction as much as needed to cover most of the background image painting area, without clipping an image. If it doesn't cover exactly the area, the tiles are resized in that direction in order to match it.
no-repeatThe image is not repeated (and hence the background image painting area will not necessarily been entirely covered). The position of the non-repeated background image is defined by the background-position CSS property.

Examples

.exampleone {
  background-image: url("logo.png");
  background-repeat: repeat-x;
}
.exampletwo {
  background-image: url("logo.png");
  background-repeat: no-repeat;
}
.examplethree {
  background-image: url("img1.png"), url("img2.png");
  background-repeat: repeat-x, repeat-y;
}
Each image is matched with the corresponding repeat style, from first specified to last.

Compatibility

Desktop browsers

FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support1.01.0 (1.7 or earlier)4.03.51.0 (85)
Multiple backgrounds1.03.6 (1.9.2)9.010.51.3 (312)
Different values for X & Y directions (two-value syntax)(Yes)13.09.0(Yes)(Yes)
round and space keywordsNot supported Not supported (bug 548372)9.010.5Not supported

Mobile browsers

FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic supportNANANANANA
Multiple backgroundsNANANANANA
Different values for X & Y directions (two-value syntax)NANANANANA
round and space keywordsNANANANANA

Relative articles