Re: images in tables

by "Michael Gerholdt" <gerholdt(at)ait.fredonia.edu>

 Date:  Sat, 17 Apr 1999 10:32:18 -0400
 To:  "Lonna Poland" <lonna(at)granbury.com>,
<hwg-graphics(at)hwg.org>
  todo: View Thread, Original
Lonna,

You have had a few responses to your question, and each of them holds
some of the answer you are looking for.

You mentioned <tr valign=top>

The 'align' and 'valign' properties go in <td>, not <tr>

cellpadding and cellspacing will have different effects. Cellpadding
will push contents of the cell x pixels away from the edge of the cell;
cellspacing will put x pixels between cells. Background will be visible
between the cells with cellspacing. I think from your question you are
looking at cellpadding rather than cellspacing, but you can play with
them.

Make sure you use closing tags </td></tr> everywhere, and very much
especially if you have one table nested inside another; Netscape in
particular will behave strangely if you do not. Technically, these tags
are optional, and it is wrong of Netscape to behave differently when
they are absent, but it does, so there isn't anything we can do about
it. (Actually, it is better to include all optional closing tags now
that XML is coming on the scene.)

Also, make sure that there is no extra space before </td> so that it
looks like 'content'</td>.

Finally, don't have a hard break between one cell and another. In other
words, <tr><td>'content1'</td><td>'content2'</td></tr> IF aligning of
image in on cell and the other is important. It is a buglet in Netscape
that it adds extra space when there is a hard return. This makes code
cramped and not as easy to read. This is most important if you have an
image which you cut into pieces and then place the pieces into table
cells and wish to have it look like the picture did before you cut it
up; you don't want extra spaces between cells. Also make sure to include
in the <table> tag border="0" to keep your cells packed together.

Since you aren't aligning parts of an image closely, all of the above
may not be immediately pertinent to what you are doing, but there will
come a time! Knowing some of this ahead of time will save you some
headaches.

I almost always include <table border="x" cellpadding="x"
cellspacing="x" align="center|left|right"> in every table because then I
know that individual browsers aren't going to use a default for
unspecified properties/attributes but will instead use what I specify.

One of your responses suggested that you can use cellpadding in <td> but
not cellspacing. The latter makes sense, of course; cellspacing isn't
about one cell, but about how all cells relate to each other. It also
makes sense that cellpadding would work in a single cell; I didn't know
that, but will check it out. It should work that you could set
cellpadding globally for the table in <table cellpadding="x" .. > and
then overide that for a given cell with <td cellpadding="y">. Again,
that's new to me but makes all the sense in the world.

Hope this helps,
Michael Gerholdt

HWG: hwg-graphics mailing list archives, maintained by Webmasters @ IWA