Chapter 38. Using Background Images in CSS Divs

Background images in table cells are either there or not, as you saw in Topic 37. You either define them in the HTML, or you don't, and the browser takes care of the rest. If the amount of content in the table cell exceeds the physical size of the image, the browser tiles the image. If this is the effect you want, then good for you. If you don't want this effect, then too bad.

Not so with background images in CSS divs. CSS provides a number of design options. You may tile the image if you like in a variety of ways, or you may display it one time and one time only. You may also specify where in the div your background image should appear.

Start with a typical div, like this:

 <div id="mercury" style="width: ...

Get Web Design Garage now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.