Background-repeat - CSS Property

background-repeat

Summary of characteristics of the background-repeat property

Quick description
Defines how the background image is repeated.
Status
Standard
Predefined values
repeat | no-repeat | repeat-x | repeat-y | round | space
Percentages
Not applicable.
Initial value
repeat
Inherited by default
No.
Discrète: during an animation, the background-repeat property passes from one value to another without transition.
Per grammar: serialization in the order of syntax.
W3C Module
CSS Backgrounds and Borders Module
 🡇  
 🡅  
Document status: CR (Candidate Recommendation)

Document status: REC (Recommendation)

Document status: DEPR (Old specification, declared obsolete or superseded)

Syntax diagram of background-repeat.

background-repeat - Syntax DiagramSyntax diagram of the background-repeat CSS property. repeat-x repeat-x repeat-y repeat-y repeat repeat no-repeat no-repeat space space round round {1,2} {1,2} , ,background-repeat:;background-repeat:;
Syntax diagram of the background-repeat property.
The links in the diagram provide more details about the values.
Download the diagram in SVG.

In the diagram, the bold terms are the predefined words of CSS, the other terms are described below:

  • In the case of multiple backgrounds, you list several values separated by a comma.

Description of the background-repeat property.

background-repeat defines how the background image is repeated across the background area surface.

Example width
background-repeat:space;
Example width
background-repeat:round;


For a general overview of background options, check out the page background.

Values for background-repeat.

  • background-repeat: repeat;

    Default value. The background image is repeated across the entire surface, without changing the original size of the image.

    repeat
  • background-repeat: no-repeat;

    The background image is displayed only once. Its position is set by the background-position property.

    no-repeat
  • background-repeat: repeat-x;

    The background image is repeated only horizontally.

    repeat-x
  • background-repeat: repeat-y;

    The background image is repeated only vertically.

    repeat-y
  • background-repeat: space;

    The background image is repeated as much as possible without cutting it. The displayed images are spread out over the surface of the background area.

    space
  • background-repeat: round;

    The background image is repeated as much as possible without cutting it. The displayed images are stretched to cover the surface of the element.

    round
  • background-repeat: space round;

    Two values can be specified, separated by a space. The first one corresponds to repetition in the horizontal direction, and the second in the vertical direction.
    However, this option to specify two values is only useful for combining round and space, as each of the other values implies both directions on its own.

    space round
  • background-repeat: round, repeat, repeat-x;

    When multiple values are specified, separated by commas, they apply to multiple backgrounds. See the page on arrière-plans multiples for more on this.

    no-repeat,repeat
  • background-repeat: initial; (repeat) background-repeat: inherit; background-repeat: revert; background-repeat: revert-layer; background-repeat: revert-rule; background-repeat: unset;

    See the following pages for more details: initial, inherit, revert, revert-layer, revert-rule, unset.

Animation of the background-repeat property.

For this animation, we used a somewhat special technique, necessary because we had to animate not only the property background-repeat, but also the label, on the pseudo-element ::after. To do this, we use custom properties (or variables).

Of course, the background-repeat property can be animated in the usual way.

background-repeat:

Access the background-repeat property via a program

Change the background repetition in Javascript.

In JavaScript, here's how to change the value of background-repeat. JavaScript offers a syntax using the typical CSS-style notation, in kebab-case (a dash to separate words), and another syntax using camel-case notation (a capital letter to separate words).

Javascript
let el = document.getElementById('id'); el.style['background-repeat'] = 'no-repeat'; // or let el = document.getElementById('id'); el.style.backgroundRepeat = 'no-repeat';

Read the background repetition in JavaScript.

This code gets the value of background-repeat if it has been set directly on the element itself using the HTML style attribute, and not through a CSS selector.

Javascript
let el = document.getElementById('id'); let value = el.style['background-repeat']; // or let el = document.getElementById('id'); let value = el.style.backgroundRepeat;

Read the computed value of background-repeat in Javascript.

The computed value is the one that results from evaluating the cascade of inheritances. This can be the value set with the HTML style attribute, a value set via a CSS selector, an inherited value, or even the initial value of the property (repeat in the case of background-repeat).

Javascript
let el = document.getElementById('id'); let value = window.getComputedStyle(el).getPropertyValue('background-repeat');

Read or write the background repeat with jQuery.

JQuery

// Read the value:
$('#id').prop('background-repeat');
// Write the value:
$('#id').prop('background-repeat', 'no-repeat');
$('#id').prop('{background-repeat': 'no-repeat'});

With JQuery, read the computed value of background-repeat.

JQuery
let value = $('#id').css('background-repeat');

Other code examples.

Other code examples for handling CSS with JavaScript and JQuery are given on the page Javascript and CSS.

Test it yourself.

The buttons below either show the assigned value of the property background-repeat or the computed value. For this property, it won't make a difference because it only accepts predefined values. However, if you try to assign an incorrect value, the assigned value will be null, and the computed value will be the property's initial value (repeat).

Simulator.

To get a good view of all the implications of background-repeat, you can shrink the browser window and watch how the background image behaves.

background-repeat :

Browsers compatibility with background-repeat.

All modern browsers handle the background-repeat property and its different values correctly.

Column 1
Support for the background-repeat property defining how the background image is repeated.
1
background-repeat
property
Estimated overall support.
96%

Browsers on computers :

Mobile browsers :

Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Safari

Safari sur IOS

Opéra

Chrome

Edge

Firefox

Chrome pour Androïd

Samsung Internet

Androïd Brower

Firefox pour Androïd

KaiOS Browser

Opéra mini

Historic of the background-repeat property.

  • Cascading Style Sheets specification - Version 1

    This first level of the CSS specification describes the mechanism of cascading style sheets. Authors and readers can add styles to documents. Mainly intended for formatting HTML documents, CSS allows defining colors, fonts, text formatting, spacing (margins), etc. The CSS language is easy to understand, readable, and easy to write; it uses common terms from desktop publishing.

    Regarding background-repeat Initial definition of the background-repeat property in the first version of CSS.
    WD
    November 17, 1995
    Working Draft.
    PR
    November 12, 1996
    Proposed for recommendation.
    REC
    December 17, 1996
    Recommendation .
    DEPR
    September 13, 2018
    Old specification, declared obsolete.
  • Cascading Style Sheets Level 2 - Revision 1 Specification

    This level 2 of the specification describes the mechanism of cascading styles in CSS. This language is used to format HTML or XML documents. It supports media-specific style sheets so that authors can adapt the presentation of their documents for visual browsers, auditory devices, printers, braille devices, portable devices, etc.

    Regarding background-repeat Acceptance of the inherit value.
    WD
    November 04, 1997
    Working Draft.
    PR
    March 24, 1998
    Proposed for recommendation.
    REC
    May 11, 1998
    Recommendation .
  • CSS Backgrounds and Borders Module Level 3

    Level 3 of the specification also explains how to position the background relative to the background area, and how to crop it.
    Regarding borders, the concept of image borders is introduced, as well as the ideas of rounded corners and box shadows.

    Regarding background-repeat Added space and round values for background-repeat.
    WD
    August 02, 2002
    Working Draft.
    CR
    December 17, 2009
    Candidate Recommendation.
    PR
    REC

See also, regarding backgrounds.

Everything about backgrounds and borders is described in the W3C specification "CSS Backgrounds and Borders Module". Here are the main properties described in this standard:

Properties:

background
Summary of background properties.
background-attachment
Background image scrolling mode.
background-clip
Defines the extent of the background, especially in relation to the border and padding.
background-color
Sets the background color.
background-image
Defines the background image or gradient (multiple images or gradients can coexist).
background-origin
Defines a reference to position the background image.
background-position
Defines how the background image is positioned.
background-position-block
Sets the background positioning in the block direction.
background-position-inline
Sets the background positioning along the lines.
background-position-x
Sets how the background image is positioned horizontally.
background-position-y
Defines how the background image is positioned in the vertical direction.
Background-repeat
Defines how the background image is repeated.
background-size
Sizing the background image.
border
A shorthand property that defines the set of border parameters: width, style and color.
border-bottom
Sets the parameters of the bottom border of the element (thickness, line style, color).
border-bottom-color
Sets the border line color for the bottom of the element.
border-bottom-left-radius
Sets the radius of the rounded corner at the bottom left.
border-bottom-right-radius
Sets the radius of the rounded corner in the lower right.
border-bottom-style
Sets the line style for the border below the element.
border-bottom-width
Sets the thickness of the border line located below the element.
border-color
Sets the border color for all four sides of the element.
border-end-end-radius
Sets the radius of the corner rounding at the end of line and end of block.
border-end-start-radius
Sets the radius of the corner rounding at the end of line and beginning of the block.
border-image
Langue française
Shorthand of border properties made with images.
border-image-outset
Langue française
Sets the overflow of the border image.
border-image-repeat
Langue française
Defines how the border image is repeated or expanded to cover the desired area.
border-image-slice
Langue française
Defines how the border image is clipped.
border-image-source
Sets the path and file name for the image used to build the border.
border-image-width
Langue française
Sets the thickness of the border when the border is made with an image.
border-left
Sets the three parameters of the left border of the element (thickness, line style, color).
border-left-color
Sets the color of the left border line of the element.
border-left-style
Sets the border style for the left side of the element.
border-left-width
Sets the thickness of the border on the left side of the element.
border-radius
Radius of rounded corners.
border-right
Sets the three parameters of the right border of the element (thickness, line style, color).
border-right-color
Sets the color of the border line on the right side of the element.
border-right-style
Sets the line style for the right border of the element.
border-right-width
Sets the thickness of the border on the right side of the element.
border-start-end-radius
Sets the radius of the corner rounding at the beginning of the line and the end of the block.
border-start-start-radius
Sets the radius of the corner rounding at the beginning of the line and the beginning of the block.
border-style
Sets the line type for some or all four borders around the element (solid, double, dotted...).
border-top
Sets the parameters of the top border of the element (thickness, line style, color).
border-top-color
Sets the color of the border line above the element.
border-top-left-radius
Sets the radius of the rounded corner at the top left.
border-top-right-radius
Sets the radius of the rounded corner in the upper-right.
border-top-style
Sets the line style for the left border of the element.
border-top-width
Sets the thickness of the border line above the element.
border-width
Sets the thickness of the border line around the element.
box-shadow
Applies a shading effect to the frames by indicating all the parameters: color, shadow shift, blur, etc.