Producing web pages
* HTML CSS DHTML XHTML A to Z of tags        Accessibility          Design

background-repeat

The background-repeat property controls if, or how, a background picture tiles. You don’t often get a picture that exactly matches the size of the browser window. For example, if you change the size of the browser window, the browser rejigs the content to fit. If a picture is too small to fill the window, the browser repeats it over and over again to fill the window. This is known as tiling.

Some times tiling works a treat; it gives seamless repeating pattern that fills an area of any size. Sometimes, tiling looks awful. So, you can decide whether you want a picture to tile or not. If you do want to, you can tell the browser how to tile the picture.

Here’s an example that turns tiling off:

body {background-image: url("back.jpg"); 
      background-repeat: no-repeat;}

Your options are:

  • Use the value repeat-x to repeat the picture horizontally. The picture only appears once vertically, regardless of the height of the tag or window
  • Use the value repeat-y to repeat the picture vertically. The picture only appears once horizontally, regardless of the width of the tag or window
  • Repeat the picture in both directions (the default). Use the value repeat
  • Don’t repeat the picture. The picture displays once; it doesn’t tile. Use the value no-repeat