CSS background-repeat property

The background-repeat property can be used to set how a background image will repeat on a page.

This property is NOT inherited

Possible values

Value Description
repeat Repeat the background image horizontally & vertically (default)
repeat-x Repeat the background image only horizontally
repeat-y Repeat the background image only vertically
no-repeat Do not repeat the background image, display just once

Example

div.one {background-image: url(/images/ob020.jpg); background-repeat: repeat-x;} div.two {background-image: url(/images/bricks.jpg); background-repeat: repeat-y;} <div class="one">This container has a horizontally repeating background image</div> <div class="two">This container has a vertically repeating background image</div>
Output:
This container has a horizontally repeating background image
This container has a vertically repeating background image

Javascript

You can access this property with Javascript:

element.style.backgroundRepeat = "repeatType";

Other background properties

background
background-attachment
background-color
background-image
background-position

CSS background examples

Setting a background color
Setting a background color for a table
Setting a background image for a page
Setting a background image for a table
Setting a background image that does not move
Setting a background image that repeats horizontally
Setting a background image that repeats vertically
Setting a background image that repeats for the whole page
Setting a background image that is center positioned
Setting a background image that is center positioned and does not move
Setting all the background properties with one declaration

More CSS examples

Web Reference
  1. CSS reference
  2. HTML reference
  3. RSS reference

© Copyright 2011-2012 Landofcode.com
Terms of use | Privacy policy | Copyright information | Make a donation