table cell size

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ivo

    table cell size

    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"><in put type="text"></td>
    </tr>
    <tr>
    <td colspan="2">mor e text</td>
    <td width="10"><inp ut 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

    #2
    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"><in put type="text"></td>
    > </tr>
    > <tr>
    > <td colspan="2">mor e text</td>
    > <td width="10"><inp ut 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:30 0px;">
    <tr class="invisibl e"><td style="width:10 0px;"></td><td
    style="width:19 0px;"></td><td style="width:10 px"></td></tr>
    <tr>
    <td>some text</td>
    <td colspan="2"><in put type="text"></td>
    </tr>
    <tr>
    <td colspan="2">mor e 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

    Comment

    • Ivo

      #3
      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"><in put type="text"></td>
      > > </tr>
      > > <tr>
      > > <td colspan="2">mor e text</td>
      > > <td width="10"><inp ut 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:30 0px;">
      > <tr class="invisibl e"><td style="width:10 0px;"></td><td
      > style="width:19 0px;"></td><td style="width:10 px"></td></tr>
      > <tr>
      > <td>some text</td>
      > <td colspan="2"><in put type="text"></td>
      > </tr>
      > <tr>
      > <td colspan="2">mor e 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:ri ght;">
      <input type="checkbox" >
      </span>
      more text
      </td>
      </tr>

      Thanks again,
      Ivo


      Comment

      • jmm-list-gn

        #4
        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)

        Comment

        • Harlan Messinger

          #5
          Re: table cell size


          "Els" <els.aNOSPAM@ti scali.nl> wrote in message
          news:Xns952D154 BEAFC7Els@130.1 33.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"><in put type="text"></td>
          > > </tr>
          > > <tr>
          > > <td colspan="2">mor e text</td>
          > > <td width="10"><inp ut 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.

          Comment

          • Els

            #6
            Re: table cell size

            Harlan Messinger wrote:
            [color=blue]
            > "Els" <els.aNOSPAM@ti scali.nl> wrote in message
            > news:Xns952D154 BEAFC7Els@130.1 33.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"><in put type="text"></td>
            >> > </tr>
            >> > <tr>
            >> > <td colspan="2">mor e text</td>
            >> > <td width="10"><inp ut 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
            Blog and other pages, mostly outdated.

            Sonhos vem. Sonhos vão. O resto é imperfeito.
            - Renato Russo -

            Comment

            Working...