minimum width for table cols ignored

Discussion in 'HTML' started by Aaron Fude, May 19, 2004.

  1. Aaron Fude

    Aaron Fude Guest

    Hi,

    I'm sure that this is a common problem so there's probably a source with all
    the answers that I want.

    I find that my width attribute in td and th tags is not honored - I end up
    with narrower columns. This usually happens when the table has very many
    colums and doesn't fit. I use css for layout so my table is inside an
    absolutely positioned div - may be that's what's causing the problem?

    In any case, has anyone had similar problems? If so, do you have any
    suggestions? A good article to read?

    Thank you,

    Aaron
     
    Aaron Fude, May 19, 2004
    #1
    1. Advertising

  2. "Aaron Fude" <> wrote:

    > I find that my width attribute in td and th tags is not honored - I
    > end up with narrower columns.


    By definition, the width attribute for td and th elements specifies a
    _suggested_ width, and in practice it normally acts as a _minimum_ width.
    However, e.g. incompatible width attributes might conceivably result in
    smaller widths being used.

    > This usually happens when the table has
    > very many colums and doesn't fit.


    URL?

    > I use css for layout so my table is
    > inside an absolutely positioned div - may be that's what's causing
    > the problem?


    Maybe. URL?

    But what would you _like_ to happen? If a table does not fit, what should
    a browser do? Using table-layout: fixed in CSS might produce more
    predictable results, but it surely creates a large number of potential
    problems.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
     
    Jukka K. Korpela, May 19, 2004
    #2
    1. Advertising

  3. Aaron Fude

    Mitja Guest

    Aaron Fude <>
    (news:c8e87i$2gfe$) wrote:
    > Hi,
    >
    > I'm sure that this is a common problem so there's probably a source
    > with all the answers that I want.
    >
    > I find that my width attribute in td and th tags is not honored - I
    > end up with narrower columns. This usually happens when the table has
    > very many colums and doesn't fit. I use css for layout so my table is
    > inside an absolutely positioned div - may be that's what's causing
    > the problem?
    >
    > In any case, has anyone had similar problems? If so, do you have any
    > suggestions? A good article to read?


    Sometimes the browsers do some "optimisations", e.g. shrinking the table so
    it fits the viewport. <table style="table-layout:fixed"> might do the trick.

    >
    > Thank you,
    >
    > Aaron
     
    Mitja, May 19, 2004
    #3
  4. Jukka K. Korpela wrote:
    [snip]
    > But what would you _like_ to happen? If a table does not fit, what
    > should a browser do? Using table-layout: fixed in CSS might produce
    > more predictable results, but it surely creates a large number of
    > potential problems.


    I believe it is not supported by IE-Mac, or earlier browsers?

    (It typically, as you imply, isn't a good answer).

    --
    Barry Pearson
    http://www.Barry.Pearson.name/photography/
    http://www.BirdsAndAnimals.info/
    http://www.ChildSupportAnalysis.co.uk/
     
    Barry Pearson, May 19, 2004
    #4
  5. Aaron Fude wrote:
    > Hi,
    > I'm sure that this is a common problem so there's probably a source
    > with all the answers that I want.
    >
    > I find that my width attribute in td and th tags is not honored - I
    > end up with narrower columns. This usually happens when the table has
    > very many colums and doesn't fit. I use css for layout so my table is
    > inside an absolutely positioned div - may be that's what's causing
    > the problem?

    [snip]

    Tables are inherently difficult to control. They were intended to be that way,
    and to adapt to the user's viewing conditions. I believe the best thing to do
    with tables is to accept that they work best when their size is hardly
    controlled at all. They are for positioning material in rows & columns, not
    for pixel-level sizing.

    If you want to control the sizes of table cells, control the content, not the
    table. Then the table will simply adapt to the content. For example:

    HTML:
    <td>
    <div class="width1">
    content of the cell goes here
    </div>
    </td>

    CSS:
    div.width1 {
    width: 200px;
    overflow: auto:
    }

    If you want a minimum width, you could use a spacer-div. Put a zero-content
    div in the cell, and control its width via CSS. (It is the modern equivalent
    of a spacer-GIF).

    --
    Barry Pearson
    http://www.Barry.Pearson.name/photography/
    http://www.BirdsAndAnimals.info/
    http://www.ChildSupportAnalysis.co.uk/
     
    Barry Pearson, May 19, 2004
    #5
  6. Aaron Fude

    Aaron Fude Guest

    Thank you for all the answers. Basically, problems arise in one situation.
    When I
    1. ...have way too much data to fit accross the screen (It just is and
    supposed to be and my clients don't mind srolling. It's just a darn long
    table!).
    2. ...have two such tables and I want the columns to align.

    Once you accept that the 'width' is a suggestion, I don't really see how to
    achieve this. I guess spacer-div is the answer. Barry, can you point out an
    example?

    Unfortunately, I couldn't post a URL highlighting my problem since it would
    be a little bit of a project for to obfuscate proprietary data.

    Once again, thank you all who replied to my question! Very educational.

    Aaron Fude

    "Barry Pearson" <> wrote in message
    news:M0Oqc.146$...
    > Aaron Fude wrote:
    > > Hi,
    > > I'm sure that this is a common problem so there's probably a source
    > > with all the answers that I want.
    > >
    > > I find that my width attribute in td and th tags is not honored - I
    > > end up with narrower columns. This usually happens when the table has
    > > very many colums and doesn't fit. I use css for layout so my table is
    > > inside an absolutely positioned div - may be that's what's causing
    > > the problem?

    > [snip]
    >
    > Tables are inherently difficult to control. They were intended to be that

    way,
    > and to adapt to the user's viewing conditions. I believe the best thing to

    do
    > with tables is to accept that they work best when their size is hardly
    > controlled at all. They are for positioning material in rows & columns,

    not
    > for pixel-level sizing.
    >
    > If you want to control the sizes of table cells, control the content, not

    the
    > table. Then the table will simply adapt to the content. For example:
    >
    > HTML:
    > <td>
    > <div class="width1">
    > content of the cell goes here
    > </div>
    > </td>
    >
    > CSS:
    > div.width1 {
    > width: 200px;
    > overflow: auto:
    > }
    >
    > If you want a minimum width, you could use a spacer-div. Put a

    zero-content
    > div in the cell, and control its width via CSS. (It is the modern

    equivalent
    > of a spacer-GIF).
    >
    > --
    > Barry Pearson
    > http://www.Barry.Pearson.name/photography/
    > http://www.BirdsAndAnimals.info/
    > http://www.ChildSupportAnalysis.co.uk/
    >
    >
     
    Aaron Fude, May 21, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HoustonFreeways

    Table/Div: want max width but no minimum

    HoustonFreeways, Apr 6, 2004, in forum: HTML
    Replies:
    6
    Views:
    30,621
    Weyoun the gowd damn Dominion Vorta who certainly
    Apr 6, 2004
  2. phl
    Replies:
    2
    Views:
    1,972
  3. Replies:
    3
    Views:
    762
  4. HP
    Replies:
    3
    Views:
    425
    Ben C
    Mar 9, 2007
  5. solenero

    resizable table cols

    solenero, Oct 11, 2005, in forum: Javascript
    Replies:
    1
    Views:
    315
    Baconbutty
    Oct 12, 2005
Loading...

Share This Page