CSS background-repeat Property
Example
Repeat the background-image only vertically:
body
{
background-image:
url
('
paper
.
gif
')
;
background-repeat:
repeat-y
;
}
Try it »
Tag Definition and Usage Notes
The background-image property sets how an object is tiled.
By default, a background-image is repeated both vertically and horizontally.
| Default value: | repeat |
|---|---|
| Inherited: | no |
| Version: | CSS1 |
| JavaScript syntax: | object object.style.backgroundRepeat="repeat-y" |
Browser support
The numbers in the table indicate the first browser version that supports this property.
A number immediately before -webkit-, -ms-, or -moz- indicates the first browser version that supports that prefixed property.
<
| property | |||||
|---|---|---|---|---|---|
| background-repeat | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
IE8 and earlier browsers do not support multiple background images on a single element.
Note IE7 and earlier do not support the "inherit" value. IE8 requires a !DOCTYPE definition. IE9 supports "inherit".
Tips and Notes
**Tip:** The background-position property sets the background image position. If no position is specified, the image is always placed in the top-left corner of the element.
Attribute values
| Value | Description |
|---|---|
| repeat | The background image is repeated both vertically and horizontally. This is the default |
| repeat-x | The background image is repeated only horizontally |
| repeat-y | The background image is repeated only vertically |
| no-repeat | The background-image is not repeated |
| inherit | Specifies that the background-repeat setting should be inherited from the parent element |
Online example
How to repeat a background image both vertically and horizontally
This example demonstrates how to repeat a background image both vertically and horizontally.
How to repeat a background image only horizontally
This example demonstrates how to repeat a background image only horizontally.
How to display a background image only once
This example demonstrates how to display a background image only once, without repetition.
Related Articles
CSS Tutorial: CSS Background
CSS Reference Manual: background-position property