CSS - background-repeat

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 axes, or not repeated at all.



        <div class="one"></div>
        <div class="two"></div>
        <div class="three"></div>
        <div class="four"></div>
        <div class="five"></div>
        <div class="six"></div>
    <li>repeat-x, repeat-y (multiple images)
        <div class="seven"></div>


/* Shared for all DIVS in example */
ol, li {
  margin: 0;
  padding: 0;
li {
  margin-bottom: 12px;
div {
    background-image: url(https://mdn.mozillademos.org/files/12005/starsolid.gif);
    width: 160px;
    height: 70px;

/* background repeat CSS */
.one {
    background-repeat: no-repeat;
.two {
    background-repeat: repeat;
.three {
    background-repeat: repeat-x;
.four {
    background-repeat: repeat-y;

.five {
   background-repeat: space;

.six {
   background-repeat: round;

/* Multiple images */
.seven {
    background-image:  url(https://mdn.mozillademos.org/files/12005/starsolid.gif),
    background-repeat: repeat-x,
    height: 144px;


In this example, each list item is matched with a different value of background-repeat.


/* One-value syntax */
background-repeat: repeat-x;
background-repeat: repeat-y;
background-repeat: repeat;
background-repeat: space;
background-repeat: round;
background-repeat: no-repeat;

/* Two-value syntax: horizontal | vertical */
background-repeat: repeat space;
background-repeat: repeat repeat;
background-repeat: round space;
background-repeat: no-repeat round;

background-repeat: inherit;


The one-value syntax is a shorthand for the full two-value syntax:
Single value Two-value equivalent
repeat-x repeat no-repeat
repeat-y no-repeat repeat
repeat repeat repeat
space space space
round round round
no-repeat no-repeat no-repeat
In the two-value syntax, the first value represents the horizontal repetition behavior and the second value represents the vertical behavior. Here is an explanation of how each option works for either direction:
repeat The image is repeated as much as needed to cover the whole background image painting area. The last image will be clipped if it doesn't fit.
space The image is repeated as much as possible without clipping. The first and last images are pinned to either side of the element, 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 isn't enough room to display one image.
round As the allowed space increases in size, the repeated images will stretch (leaving no gaps) until there is room for another one to be added. When the next image is added, all of the current ones compress to allow room. Example: An image with an original width of 260px, repeated three times, might stretch until each repetition is 300px wide, and then another image will be added. They will then compress to 225px.
no-repeat The image is not repeated (and hence the background image painting area will not necessarily be entirely covered). The position of the non-repeated background image is defined by the background-position CSS property.

Formal syntax

<a href="css/background-repeat#repeat-style"><repeat-style></a><a href="css/value_definition_syntax#hash_mark_(.23)" title="Hash mark">#</a><p>where <br><code><repeat-style> = repeat-x <a href="css/value_definition_syntax#single_bar" title="Single bar">|</a> repeat-y <a href="css/value_definition_syntax#single_bar" title="Single bar">|</a> <a href="css/value_definition_syntax#brackets" title="Brackets">[</a>repeat <a href="css/value_definition_syntax#single_bar" title="Single bar">|</a> space <a href="css/value_definition_syntax#single_bar" title="Single bar">|</a> round <a href="css/value_definition_syntax#single_bar" title="Single bar">|</a> no-repeat<a href="css/value_definition_syntax#brackets" title="Brackets">]</a><a href="css/value_definition_syntax#curly_braces_(.7b_.7d)" title="Curly braces">{</a>1,2<a href="css/value_definition_syntax#curly_braces_(.7b_.7d)" title="Curly braces">}</a></code></p>


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 axes, or not repeated at all.

By default, the repeated images are clipped to the size of the element, but they can be scaled to fit (using round) or evenly distributed from end to end (using space).

Initial valuerepeat
Applies toall elements. It also applies to ::first-letter and ::first-line.
Computed valuea list, each item consisting of two keywords, one per dimension
Canonical orderthe unique non-ambiguous order defined by the formal grammar

Browser Compatibility  

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 1.0 (1.7 or earlier) 4.0 3.5 1.0 (85)
Multiple backgrounds 1.0 3.6 (1.9.2) 9.0 10.5 1.3 (312)
Different values for X & Y directions (two-value syntax) (Yes) 13.0 (13.0)[1] 9.0 (Yes) (Yes)
round and space keywords (Yes) 49.0 (49.0)[2] 9.0 10.5 (Yes)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? (Yes) ? ? ?
Multiple backgrounds ? (Yes) ? ? ?
Different values for X & Y directions (two-value syntax) ? (Yes) ? ? ?
round and space keywords ? 49.0 (49.0)[2] ? ? ?

[1] Implemented in bug 548375.

[2] This feature was implemented in bug 548372.

See Also  


Specification Status Comment
CSS Backgrounds and Borders Module Level 3
The definition of 'background-repeat' in that specification.
Candidate Recommendation Added support for multiple background images, the two-value syntax allowing distinct repetition behavior for the horizontal and vertical directions, the space and round keywords, and for backgrounds on inline-level element by defining precisely the background painting area.
CSS Level 2 (Revision 1)
The definition of 'background-repeat' in that specification.
Recommendation No significant changes
CSS Level 1
The definition of 'background-repeat' in that specification.
Recommendation Initial definition


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

CSS CSS Background CSS Property NeedsMobileBrowserCompatibility Reference