Main Page Content
Some Helpful Table Tricks
Although tables were never meant to be used for layout purposes, many will agree that they are one of the most useful tools in our web design arsenal - at least, until stylesheets take over and become universally accepted. Even then, tables will still be useful for certain applications.
Here are a number of useful tricks found while working with tables:Use TR to save extra code
First of all, you don't need to declare certain attributes in all of your <TD> tags. Instead, just put it in your <TR> tag and all of the cells within that <TR> tag will inherit those attributes. For example:<TR VALIGN="top" ALIGN="center" BGCOLOR="white"><TD>Cell 1</TD><TD>Cell 2</TD></TR>is the same as:
<TR><TD VALIGN="top" ALIGN="center" BGCOLOR="white">Cell 1</TD><TD VALIGN="top" ALIGN="center" BGCOLOR="white">Cell 2</TD></TR>
Width inheritance
You don't need to declare widths for all of your cells, either. This one is a little more tricky, since Netscape and MSIE render tables slightly differently. I'd suggest only doing this for absolute width tables, where you're declaring widths in pixels. For example:<TABLE WIDTH="200"><TR><TD WIDTH="100">Cell 1</TD><TD WIDTH="100">Cell 2</TD></TR><TR><TD>Cell 3</TD><TD>Cell 4</TD></TR></TABLE>is the same as:
<TABLE WIDTH="200"><TR><TD WIDTH="100">Cell 1</TD><TD WIDTH="100">Cell 2</TD></TR><TR><TD WIDTH="100">Cell 3</TD><TD WIDTH="100">Cell 4</TD></TR></TABLE>If your cell widths aren't working out correctly, just throw in a transparent .gif set to the needed width, and it will force the cell open.