Connecting Tech Pros Worldwide Forums | Help | Site Map

table cell size

Ivo
Guest
 
Posts: n/a
#1: Jul 20 '05
Consider a table with a number of rows, each containing a short text (label)
on the left and an input control on the right. Some inputs are of type text
and others of type checkbox. I would like the cells with the checkboxes to
be as narrow as possible (square) but in this table the "width=10" bit seems
to get ignored:

<table border="1">
<tr>
<td>some text</td>
<td colspan="2"><input type="text"></td>
</tr>
<tr>
<td colspan="2">more text</td>
<td width="10"><input type="checkbox"></td>
</tr>
</table>

What am I doing wrong?
The reason I am using a table is of course to line up the input elements.
More elegant solutions are also welcomed.
Thanks,
Ivo



Els
Guest
 
Posts: n/a
#2: Jul 20 '05

re: table cell size


Ivo wrote:
[color=blue]
> Consider a table with a number of rows, each containing a
> short text (label) on the left and an input control on the
> right. Some inputs are of type text and others of type
> checkbox. I would like the cells with the checkboxes to be
> as narrow as possible (square) but in this table the
> "width=10" bit seems to get ignored:
>
> <table border="1">
> <tr>
> <td>some text</td>
> <td colspan="2"><input type="text"></td>
> </tr>
> <tr>
> <td colspan="2">more text</td>
> <td width="10"><input type="checkbox"></td>
> </tr>
> </table>
>
> What am I doing wrong?[/color]

Nothing, really, (I think!), but you didn't define the "middle
cell".
If you put this:
<tr><td></td><td></td><td></td></tr>
right above the first <tr>, it does work in Firefox.
Colspan is a bit tricky, and different browsers act
differently with it.
I've learned to set all widths in the first line which has
only td's without colspan, then use colspan as you see fit on
the cells in the rows below.
You can make that first row invisible if you'd use CSS.
Like this:
In the <head>
<style type="text/css">
table, td {border:1px solid black}
tr.invisible td{border:0px;}
</style>
In the <body>
<table style="width:300px;">
<tr class="invisible"><td style="width:100px;"></td><td
style="width:190px;"></td><td style="width:10px"></td></tr>
<tr>
<td>some text</td>
<td colspan="2"><input type="text"></td>
</tr>
<tr>
<td colspan="2">more text</td>
<td><input type="checkbox"></td>
</tr>
</table>

hth

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: Meredith Brooks - I'm A Bitch
Ivo
Guest
 
Posts: n/a
#3: Jul 20 '05

re: table cell size


"Els" wrote[color=blue]
> Ivo wrote:[color=green]
> > Consider a table with a number of rows, each containing a
> > short text (label) on the left and an input control on the
> > right. Some inputs are of type text and others of type
> > checkbox. I would like the cells with the checkboxes to be
> > as narrow as possible (square) but in this table the
> > "width=10" bit seems to get ignored:
> >
> > <table border="1">
> > <tr>
> > <td>some text</td>
> > <td colspan="2"><input type="text"></td>
> > </tr>
> > <tr>
> > <td colspan="2">more text</td>
> > <td width="10"><input type="checkbox"></td>
> > </tr>
> > </table>
> >
> > What am I doing wrong?[/color]
>
> Nothing, really, (I think!), but you didn't define the "middle
> cell".
> If you put this:
> <tr><td></td><td></td><td></td></tr>
> right above the first <tr>, it does work in Firefox.
> Colspan is a bit tricky, and different browsers act
> differently with it.[/color]

Is that so? Never noticed. I 'd think that ancient table stuff would be
pretty much standardized by now.
[color=blue]
> I've learned to set all widths in the first line which has
> only td's without colspan, then use colspan as you see fit on
> the cells in the rows below.
> You can make that first row invisible if you'd use CSS.
> Like this:
> In the <head>
> <style type="text/css">
> table, td {border:1px solid black}
> tr.invisible td{border:0px;}
> </style>
> In the <body>
> <table style="width:300px;">
> <tr class="invisible"><td style="width:100px;"></td><td
> style="width:190px;"></td><td style="width:10px"></td></tr>
> <tr>
> <td>some text</td>
> <td colspan="2"><input type="text"></td>
> </tr>
> <tr>
> <td colspan="2">more text</td>
> <td><input type="checkbox"></td>
> </tr>
> </table>[/color]

Thank you for your ideas, but the checkbox cell is still wider than it needs
to be, and I 'd rather not rely on fixed pixels as I can't know the lengths
of the texts beforehand.
In other experiments, I am having more success with this approach:
<tr>
<td>some text</td>
<td><input type="text"></td>
</tr>
<tr>
<td colspan="2">
<span style="float:right;">
<input type="checkbox">
</span>
more text
</td>
</tr>

Thanks again,
Ivo


jmm-list-gn
Guest
 
Posts: n/a
#4: Jul 20 '05

re: table cell size


Ivo wrote:[color=blue]
>
> Thank you for your ideas, but the checkbox cell is still wider than it needs
> to be, and I 'd rather not rely on fixed pixels as I can't know the lengths
> of the texts beforehand.
>
>[/color]
The width attribute only sets a *minimum* value for the column.

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Harlan Messinger
Guest
 
Posts: n/a
#5: Jul 20 '05

re: table cell size



"Els" <els.aNOSPAM@tiscali.nl> wrote in message
news:Xns952D154BEAFC7Els@130.133.1.4...[color=blue]
> Ivo wrote:
>[color=green]
> > Consider a table with a number of rows, each containing a
> > short text (label) on the left and an input control on the
> > right. Some inputs are of type text and others of type
> > checkbox. I would like the cells with the checkboxes to be
> > as narrow as possible (square) but in this table the
> > "width=10" bit seems to get ignored:
> >
> > <table border="1">
> > <tr>
> > <td>some text</td>
> > <td colspan="2"><input type="text"></td>
> > </tr>
> > <tr>
> > <td colspan="2">more text</td>
> > <td width="10"><input type="checkbox"></td>
> > </tr>
> > </table>
> >
> > What am I doing wrong?[/color]
>
> Nothing, really, (I think!), but you didn't define the "middle
> cell".
> If you put this:
> <tr><td></td><td></td><td></td></tr>
> right above the first <tr>, it does work in Firefox.
> Colspan is a bit tricky, and different browsers act
> differently with it.
> I've learned to set all widths in the first line which has
> only td's without colspan, then use colspan as you see fit on
> the cells in the rows below.
> You can make that first row invisible if you'd use CSS.[/color]

The COL element is available for just this purpose, rather than using an
invisible row.

Els
Guest
 
Posts: n/a
#6: Jul 20 '05

re: table cell size


Harlan Messinger wrote:
[color=blue]
> "Els" <els.aNOSPAM@tiscali.nl> wrote in message
> news:Xns952D154BEAFC7Els@130.133.1.4...[color=green]
>> Ivo wrote:
>>[color=darkred]
>> > Consider a table with a number of rows, each containing
>> > a short text (label) on the left and an input control on
>> > the right. Some inputs are of type text and others of
>> > type checkbox. I would like the cells with the
>> > checkboxes to be as narrow as possible (square) but in
>> > this table the "width=10" bit seems to get ignored:
>> >
>> > <table border="1">
>> > <tr>
>> > <td>some text</td>
>> > <td colspan="2"><input type="text"></td>
>> > </tr>
>> > <tr>
>> > <td colspan="2">more text</td>
>> > <td width="10"><input type="checkbox"></td>
>> > </tr>
>> > </table>
>> >
>> > What am I doing wrong?[/color]
>>
>> Nothing, really, (I think!), but you didn't define the
>> "middle cell".
>> If you put this:
>> <tr><td></td><td></td><td></td></tr>
>> right above the first <tr>, it does work in Firefox.
>> Colspan is a bit tricky, and different browsers act
>> differently with it.
>> I've learned to set all widths in the first line which has
>> only td's without colspan, then use colspan as you see fit
>> on the cells in the rows below.
>> You can make that first row invisible if you'd use CSS.[/color]
>
> The COL element is available for just this purpose, rather
> than using an invisible row.[/color]

Must admit, never used it. So I'll just take your word for
that :-)

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Closed Thread