Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > minimum width for table cols ignored

Reply
Thread Tools

minimum width for table cols ignored

 
 
Aaron Fude
Guest
Posts: n/a
 
      05-19-2004
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


 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      05-19-2004
"Aaron Fude" <(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
 
Mitja
Guest
Posts: n/a
 
      05-19-2004
Aaron Fude <(E-Mail Removed)>
(news:c8e87i$2gfe$(E-Mail Removed)) 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



 
Reply With Quote
 
Barry Pearson
Guest
Posts: n/a
 
      05-19-2004
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/


 
Reply With Quote
 
Barry Pearson
Guest
Posts: n/a
 
      05-19-2004
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/


 
Reply With Quote
 
Aaron Fude
Guest
Posts: n/a
 
      05-21-2004
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" <(E-Mail Removed)> wrote in message
news:M0Oqc.146$(E-Mail Removed)...
> 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/
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
html table cols mix % with pixels ptdorf@gmail.com HTML 3 03-28-2007 12:32 PM
Need directions with 3-cols fixed width/height layout with expandable images on both sides of text HP HTML 3 03-09-2007 04:38 PM
hot to align inner table cols with outer table cols phl HTML 2 05-23-2006 10:58 AM
resizable table cols solenero Javascript 1 10-12-2005 08:02 AM
Re: resized image in table extends table width to original image width Sean Jorden HTML 1 08-19-2003 08:59 AM



Advertisments