Absolute cell width in table


#1

Hello!
When I make a table like this, the cell's width between cell1 and cell2 is not 10px.

Is it possible to make table so that cells's width stays 10 pixels whitout define more width's?

example:

<table border="1">
<tr>
<td colspan="3">
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text</td>
</tr>
<tr>
<td>
cell1</td>
<td width="10"></td>
<td>
cell2</td>
</tr>
</table>

#2

Do these two things:

First, use css in the cell you want to set the width of, instead of "width="10"":

<td style="width: 10px;"></td>

Also, you might need to set the widths of cell1 and cell2 in the same way. That worked for me when I tested it.


#3

It's never going to work unless you set a width on the table itself. If your numbers are not adding up to a particular table width, IE will surely ignore all your efforts. Somebody please prove me wrong!


#4

Why this is important, if I may ask?


#5

So is this the smartest way to do it? confused

<table border="1">
<tr>
<td colspan="3">
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text</td>
</tr>
<tr>
<td width="50%">
cell1</td>
<td width="10"><TABLE width="10"></TABLE></td>
<td width="50%">
cell2</td>
</tr>
</table>

#6

I can't prove you wrong, so I guess you are right. Good idea actually to set a table width...


#7

An empty <TABLE> is not valid HTML, and even in the arcane days before CSS, people had better ways of forcing a space between table columns, like a 10 pixel wide clear image.

Let me make this suggestion instead, though:

<table border="1">
<tr>
<td colspan="2">
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text</td>
</tr>
<tr>
<td width="50&#37;" style="padding-right: 10px">
cell1</td>
<td width="50%">
cell2</td>
</tr>
</table>

#8

style="padding-right: 10px"

That is a good idea smile


#9