|
The values for aligning an entire table
are:
align=right pushes everything against the
right side.
align=left pushes everything against the
left side. (This is the default setting.)
align=center centers everything in the
middle.
We can also line text or images up vertically,
pushing it toward the top, bottom, or middle of the cells
by using valign:
<td valign=top> aligns anything you
put in that cell (text, images, etc.) at the top.
<tr valign=top> aligns anything you
put in all the cells of that row with the top.
The values for vertical alignment are:
valign=top pushes everything to the top
of the cell.
valign=bottom pushes everything to the
bottom of the cell.
valign=middle centers everything in the
middle vertically. (This is the default, so you probably
won't ever need to do it.)
Spacing
You may want to adjust the spacing of the
cells. Here are two tags that do really similar things that
you'll probably mix up a lot: cell spacing and cell padding.
They both put a little
space between the cells of your table, but they do it in
different ways. cell spacing makes the border of the table
fatter, increasing the distance between cells. cell padding
adds invisible space inside the border of the cells, which
pushes the cell's contents away from the border on all
four sides.
| cellspacing=8
|
cellpadding=8
|
Both attributes go in the table tag, like
so:
<table cell padding="4" cell spacing="5">
If
you're planning on leaving the table borders off, it really
doesn't matter which you use. But if you're going to leave
the borders on or add color to your table cells the difference
between the two tags will become important.
Tips and tricks
If you don't specify cell padding and cell
spacing, they default to the number 2. So if you really want
your cell contents to get close and personal, be sure to
specify cell padding=0 and cell spacing=0
For more control, put no wrap in your table
cell, like so: <td nowrap>. This means that no text
in that cell will wrap, unless you manually break it with
the <br> tag.
To make a table take up the entire page
no matter how big the user makes it set the width and
height at 100%, like so: <table width="100%"
height="100%">
|