CSS background-repeat

View Output Full Screen Preview

The CSS background-repeat property is used to specify if a background image repeats (tiles) or not, and how it should repeat.

By default, background images repeat horizontally and vertically across the width and height of the background painting area. However, you can change this behavior with the background-repeat property.

You can stop the image from repeating altogether (so that it only appears once), or you can specify exactly how it repeats, especially when also using the background-position and/or the background-size property.

The background-repeat property can also be used with multiple background images (i.e. if you specify multiple values for the background-image property).

Syntax

Where

Possible Values

repeat
Background repeats both horizontally and vertically. Computes to repeat repeat.
repeat-x
Background repeats horizontally only. Computes to repeat no-repeat.
repeat-y
Background repeats vertically only. Computes to no-repeat repeat.
no-repeat
Background is not repeated. Computes to no-repeat no-repeat.
round

Computes to round round.

The image is repeated as often as will fit within the background positioning area. If it doesn't fit a whole number of times, it is rescaled so that it does. If the background painting area is larger than the background positioning area, then the pattern repeats to fill the background painting area.

space

Computes to space space.

The image is repeated as much as possible to fit within the background positioning area without being clipped. The first and last images touch the edges of the area, and whitespace is distributed evenly between the images. The background-position property is ignored unless only one image can be displayed without clipping. The only case where clipping happens using space is when there's not enough room to display one image.

In addition, all CSS properties also accept the following CSS-wide keyword values as the sole component of their property value:

initial
Represents the value specified as the property's initial value.
inherit
Represents the computed value of the property on the element's parent.
unset
This value acts as either inherit or initial, depending on whether the property is inherited or not. In other words, it sets all properties to their parent value if they are inheritable or to their initial value if not inheritable.

General Information

Initial Value
repeat
Applies To
All elements
Inherited?
No
Media
Visual
Animatable
Discrete

Example Code

Official Specifications

Browser Support

Browser support for CSS properties can vary, particularly for newer or experimental features. Check current browser compatibility before using a property in production, especially when supporting older browsers.

Initial Value

CSS properties have an initial value that applies when the property has not been explicitly set. The initial value is different from the value inherited from a parent element and may vary between properties.

Inheritance

Some CSS properties inherit their computed value from their parent element by default, while others do not. The inherit, initial, unset, and revert keywords can also be used to control how a property gets its value.

Vendor Prefixes

Most modern CSS properties use the standard, unprefixed syntax. Vendor-prefixed properties such as -webkit- are mainly relevant to older browser versions or specific features and should only be used when required by your browser support targets.