Forum Moderators: open

Message Too Old, No Replies

Table TD height?

is it possible to set the height of a tables td cells?

         

bysonary

6:13 pm on May 12, 2007 (gmt 0)

10+ Year Member



I have the following HTML script.


<table border="0" width="600" cellpadding="0" cellspacing="0">
<tr>
<td width="10"><img src="topleft.png" width="10" height="10" /></td>
<td style="border-top: solid 1px #000000">&nbsp; </td>
<td width="10"><img src="topright.png" width="10" height="10" /></td>
</tr>
</table>

I really want all the td cells to be 10px in height like the image, is this possible at all?

Dabrowski

11:18 am on May 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



TD's will stretch to the size of their content, so should be the same height as the image, but you have 1 cell with an &nbsp; in it. The default font size is 16px tall, so this may be stretching the height taller than the images.

Try setting the font size on this cell to 1px. This will make it smaller than the images so the height should be the same as the image.

It's also worth noting the height applies to the row, all TD's within the row have to be the same height.

cmarshall

11:59 am on May 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you have a valid XHTML DOCTYPE, then you shouldn't need to put any kind of filler in the <td> (it can be <td></td>). I sometimes use an invisible 1-pixel shim, but I have increasingly found it to be unnecessary, and it is more of an old habit than anything else.

bysonary

12:55 am on May 14, 2007 (gmt 0)

10+ Year Member



Thanks for the info guys, i just created a transparent spacer image to fill the td.

:-)

PS - im transitional 401 at the minute

Dabrowski

3:09 pm on May 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you try cmarshall's suggestion? Just try <td></td>. The only problem you may have is that you have a border defined, sometimes if the cell is blank it won't be rendered.