Table Manners |
||
Back to the Tips n Tricks Page |
Example 1 | * | Example 2 |
This page will give you a few pointers on how to use tables in HTML to greater effect. It is not intended as the definitive guide - but should give you some ideas and demonstrate how versatile they are - I wouldn't be without 'em! All the Heading sections of my pages and the Navigation Bars are made using tables
Tables are not only for presenting information that requires a tabular format such as figures. They also have tremendous value for the web designer in overcoming some of the layout limitations of HTML.
With the border attribute set to "0" they can be used to place text or graphics on quite specific points of a page. When you consider the fact that tables can also be 'nested' - a table placed within a cell of another table - you can appreciate the uses to which they can be put.
Some examples
The coding looks like this
<TABLE WIDTH="100%" ALIGN="CENTER" BORDER="1" BORDERCOLOR="#000000">
<TR>
<TD ALIGN="left" VALIGN="top"><img src="../images/frog1.gif" border="0" width="100" height="100"></TD>
<TD ALIGN="center" VALIGN="bottom"><FONT SIZE="+2">Frogs are Cool!</FONT></TD>
<TD ALIGN="right" VALIGN="top"><img src="../images/frog2.gif" border="0" width="100" height="100"></TD>
</TR>
</TABLE>
and it displays like this
Frogs are Cool! |
without the border it looks so
Frogs are Cool! |
This is achieved by setting a background colour attribute and a specific width for the middle of three cells. If the content either side is in more than one row then you need to set a 'rowspan' attribute.
I've also used some alignment attributes to show how they might work in this sort of layout
The coding looks like this
<TABLE border="1" width="100%">
<TR>
<TD>Left side - top row contents</TD>
<TD rowspan="3" width="3" bgcolor="black"></TD>
<TD ALIGN="RIGHT">Right side - top row contents</TD>
</TR>
<TR>
<TD ALIGN="CENTER">Left side - middle row contents</TD>
<TD ALIGN="CENTER">Right side - middle row contents</TD>
</TR>
<TR>
<TD ALIGN="RIGHT">Left side - bottom row contents</TD>
<TD ALIGN="LEFT">Right side - bottom row contents</TD>
</TR>
</TABLE>
which displays like this
Left side - top row contents | Right side - top row contents | |
Left side - middle row contents | Right side - middle row contents | |
Left side - bottom row contents | Right side - bottom row contents |
and without the border ... very difficult to achieve without tables!
Left side - top row contents | Right side - top row contents | |
Left side - middle row contents | Right side - middle row contents | |
Left side - bottom row contents | Right side - bottom row contents |