Home Tables Colors Replace GIFs With Colored Table Cells
Search MS Office A-Z   |   Search Web Pages/ Design A-Z

Replace GIFs With Colored Table Cells

One of the more common page layout formats is a colored sidebar on the left or right-hand side of the page that contains navigation information, ads, links to other sites, etc. Go to any of the Web sites that offer free background images and you'll find that this is one of the most popular styles.

The key in this example is to use the ROWSPAN attribute inside your TD tag. If you want the sidebar to go the length of the page, then always be sure that ROWSPAN equals the total number of rows in the table. More complex layouts may call for a mixture of ROWSPAN and COLSPAN attributes.

<body bgcolor="#EAE6D9"> <table width="100%" cellspacing="0" cellpadding="3" border="0"> <tr width="16%"> <td width="15%" rowspan="3" bgcolor="Navy">nav bar</td> <td width="1%" rowspan="3" bgcolor="black">&nbsp;</td> <td width="84%">banner section</td> </tr> <tr> <td>content section</td> </tr> <tr> <td>footer section</td> </tr> </table> </body>

Setting attributes in the opening BODY tag is important for browser compatibility. Because Netscape and Explorer support different tags, you'll have to use all four margin attributes if you want the table borders to extend to the top and left margins of the page.

Note that we created 2 different TD tags with a colored background. The navy is the main section, while the black bar provides a clear break between the sidebar and main content section. Here's how it looks

Although this is a simple example, you can get much more creative and use the same technique to create complex sidebar and border combinations.

Simple Navigation Bars

You can also use a colored table background to replace an image map. This only works for simple image maps. If your current navigational image map is irregularly shaped, has custom buttons, or other distinctive elements, then a colored table background isn't an option.

However, if you've created a simple image map with the text in all one color and a rectangular background, then you can probably get the same effect using tables. We used the same basic layout as before, but included text for navigation links in the sidebar like this.

<table width="100%" cellspacing="0" cellpadding="3" border="0"> <tr width = "100%" > <td width="15%" rowspan="3" bgcolor="Navy" valign="top"> <br><br><br><br> <font color="white"> Products<br><br> Order<br><br> Contact Us<br><br> Home </font></td> <td width="1%" rowspan="3" bgcolor="black">&nbsp;</td> <td width="84%"><font color="black">banner</font></td> </tr> <tr> <td> <font color="black">content</font></td> </tr> <tr> <td><font color="black">footer</font></td> </tr> </table>

Note that we set VALIGN="top" to ensure that the navigation text will always display when the page loads - even if the content section is quite long. But that places the links at the very top of the table, so we used several BR tags to move it down a bit. For better control, you could place each link inside its own table cell, use borders, or nest tables.

A Few Warnings

Always remember to keep your ROWSPAN and COLSPAN attributes under control. Lay the page out on paper before you begin to code the table. It's dangerous to try to add columns and rows after the fact: your page may have big patches of colored table cells where you aren't expecting them.

There are a few other things to consider before tossing out your image maps:

Link Colors: Make sure that your hyperlink color and visited link color (LINK and VLINK) coordinate with both your table cell color and page background color. Don't deviate too much from standard link colors or you could confuse visitors.

Nested Tables: You can often get the most attractive layout results when you nest a smaller table inside your main table. Don't overuse the technique though: it can increase page download time and confuse some browsers. It's better to split up your tables on the page.

Layout Control: You have absolute control over spacing and layout in a GIF because it always displays the same. HTML is not as reliable, so you may have to use some BR tags, spacer GIFs, or other techniques to control the display and position.

Netscape Issues: Netscape doesn't display empty table cells or their background color. Be sure to include a non-breaking space or single-pixel gif inside table cells you want to display as borders.

Home Tables Colors Replace GIFs With Colored Table Cells
Search MS Office A-Z   |   Search Web Pages/ Design A-Z