English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

Comprehensive CSS Attributes

CSS background-Usage and Example of repeat Attribute

CSS background-repeat Attribute Specifiesbackground-imageWhether the background image will repeat or tile after the size and position adjustments, and how to tile. Use the shorthandBackgroundAttributes are usually more convenient.

The following table summarizes the usage context and version history of this attribute.

Default Value:repeat
Applicable To:All Elements
Inheritance:None
Animatable:No.Please See Animation Attribute.
Version:CSS 1,2,3
JavaScript Syntax:    object    object.style.backgroundRepeat="repeat-x"

Syntax of Background Repeat Usage

The syntax of this attribute is as follows:

background-repeat: repeat | repeat-x | repeat-y | no-repeat | initial | inherit

The following examples demonstrate how to use background-repeat Attribute.

body {background-image: url("images/gradient.png");background-repeat: repeat-x;}
Test See‹/›

Attribute Value

The following table describes the values of this attribute.

ValueDescription
repeatDefault Value. The background image will repeat both vertically and horizontally.
repeat-xThe background image will repeat horizontally only.
repeat-yThe background image will repeat vertically only.
no-repeatThe background image will not repeat.
initialSet this attribute to its default value.
inheritIf specified, the associated element adopts its parent element's background-Computed Value of repeat Attribute.

Browser Compatibility

background-Browser Compatibility of repeat Attribute, all mainstream browsers support this attribute.

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 4+

  • Safari 1+

  • Opera 3.5+

Further Reading

Please refer to the following tutorials:CSS Background,CSS3Background.

Related Attributes:background,background-attachment,background-color,background-clip,background-image,background-origin,background-position,background-size.