Formatting Divisions

Divisions are formatted like any other elements. You can use styles to specify the font family, font style, font weight, alignment, color, and everything else we’ve covered so far in this book.

In Chapter 12, you learned how to set the background formatting for cells in a table-based layout; you can do the same thing with divisions. For example, to make the navigation bar khaki-colored:

#topnav {float: left; width: 150px; padding-top: 15px; background-color: khaki}

When you start applying colors to divisions, however, you might uncover some underlying problems with your page. For example, our page for The Garden Company from the previous example looked pretty good when everything had a white background, but watch what happens ...

Get HTML and XHTML Step by Step 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.