XML technologies / CSS / Advanced websites with CSS / CSS property reference / background-repeat

(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)

A background image added to a page with the property background-image is tiled by default. The property background-repeat controls this behaviour.

Inherited: no

See also: background-image, background-position

Values

repeat, no-repeat, repeat-x or repeat-y.

The values repeat and no-repeat enable and disable tiling respectively; repeat-x repeats the image only horizontally. With repeat-y the image repeats only vertically.

Default value: repeat

Compatibility

CSS version: 1

Works in all CSS-capable browsers, including Internet Explorer 4 and later and Netscape 4 and later.

Internet Explorer 4 for Windows repeats the image only to the right and below, not above or to the left. This produces incomplete repetition if the image is also positioned with background-position to the right of or below the page edge.

Example

The following rule uses background-repeat and background-position to create a horizontal row of background images 50 pixels below the page’s top edge. The image’s left edge is aligned with the page’s left edge to avoid Internet Explorer 4 for Windows’ incorrect display with background-position.

body {
 background-repeat: repeat-x;
 background-position: 0 50px;
}

  

 

 

 

back to top