Skip to main content

The background-repeat Property

The CSS background-repeat property controls whether and how a background image tiles (repeats) to fill the entire area of the element. This property is crucial when using small patterns or icons as backgrounds.

By default, the browser repeats a background image horizontally and vertically until it fills the container.


Syntax and Values

The background-repeat property accepts several keyword values to define the tiling behavior.

ValueDescriptionBehavior
repeatThe default value. The image tiles horizontally and vertically to fill the element.Full tiling (X and Y).
no-repeatThe image is displayed only once at its specified background-position.No tiling.
repeat-xThe image tiles horizontally only (along the X-axis).Tiles across the width.
repeat-yThe image tiles vertically only (along the Y-axis).Tiles down the height.
spaceThe image is tiled as many times as possible without clipping, and any remaining space is distributed evenly between the tiles.Tiles with spacing.
roundThe image is tiled as many times as possible. If the tiles don't fit exactly, they are slightly resized (rounded) to ensure a whole number of tiles fit the container perfectly.Tiles with resizing.

Example

To display a logo only once in the bottom right corner:

styles.css
.footer-logo {
background-image: url('logo.png');
background-repeat: no-repeat;
background-position: right bottom;
}

Two-Value Syntax (X and Y Control)

You can also specify two values to control the X-axis and Y-axis repetition independently.

styles.css
selector {
background-repeat: <horizontal-repeat> <vertical-repeat>;
}
SyntaxEquivalentDescription
repeat no-repeatrepeat-xTiles horizontally, but not vertically.
no-repeat repeatrepeat-yTiles vertically, but not horizontally.
repeat repeatrepeatTiles both horizontally and vertically.

Interactive background-repeat Demo

Use the live editor to change the background-repeat value. The image used in this demo is a small square to clearly show the tiling effect.