HTML and CSS Reference
Listing 5-13. A background image applied to the body element
The image tiles to fill the window on the rendered page, as you can see in Figure 5-19.
Figure 5-19. The background image tiles in both directions, repeating as many times as necessary to fill the element's
area, the entire browser window in this case.
Relative URLs in CSS are relative to where the CSS file resides, not relative to where
the HTML document resides. Depending on how you organize your files on the server,
you may need to use up-level directives ( ../ ) in your CSS URLs, or use site-root-
relative URLs with leading slashes if your server is set up that way. If your background
image isn't showing up in the browser, check the file path in your image URL.
You can modify the default tiling with the background-repeat property, specifying whether the image
should repeat only horizontally, only vertically, or not at all. Listing 5-14 expands the previous CSS rule,
declaring that the background image should only repeat horizontally along the x-axis.
Listing 5-14. Adding a background-repeat declaration
You can see in Figure 5-20 that the image now repeats across the top of the page but not downward.