Click here to get back home

How do I keep apparent table width independent of window size?

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
How do I keep apparent table width independent of window size? ilya2 03-31-2008
Posted by ilya2 on March 31, 2008, 9:43 am
Please log in for more thread options
I am making an HTML table. It has a lot of columns with fixed width
(55 pixels). If I view it on full-screen IE window, the table fits on
the screen and looks just as I want it to look. When I make the window
smaller than the table, I expect horizontal scroll bar to appear.
Instead each column shrinks; a cell which had:

word1 word2
word3

becomes:

word1
word2
word3

thus distorting the table and making it look ugly. Only when I make
the window so small that columns can not shrink any more (each is the
longest word wide), does horizontal scroll bar appear.

How can I avoid this -- keep the columns same width regardless of
window size? I already tried giving the table a fixed width -- it does
not solve the problem, if anything makes it worse.

Posted by dorayme on March 31, 2008, 1:46 pm
Please log in for more thread options
In article
ilya2@rcn.com wrote:

> I am making an HTML table. It has a lot of columns with fixed width
> (55 pixels). If I view it on full-screen IE window, the table fits on
> the screen and looks just as I want it to look. When I make the window
> smaller than the table, I expect horizontal scroll bar to appear.
> Instead each column shrinks; a cell which had:
>
> word1 word2
> word3
>
> becomes:
>
> word1
> word2
> word3
>
> thus distorting the table and making it look ugly. Only when I make
> the window so small that columns can not shrink any more (each is the
> longest word wide), does horizontal scroll bar appear.
>
> How can I avoid this -- keep the columns same width regardless of
> window size? I already tried giving the table a fixed width -- it does
> not solve the problem, if anything makes it worse.

If you fix width all the cells and all the same and in pixels, you do
run into all sorts of problems; what would you want to happen, for
example, if the user upped his text size, where is the text to go if it
cannot fit?

Everything depends on the details of your project, perhaps a url might
help. But perhaps this will give you a thought to play with: Don't
bother with giving the table itself a width, try min-width in em for
either all the cells or selected cells (by classing them is most
reliable). Choose a size to fit the point below which text will wrap to
your displeasure:

td {border: 1px solid; min-width: 20em;}

In IE 6 this will be no good, but it should be ok for most other
browsers.

Or you could be variously brutal and have at least one cell in a col
that is giving you wrap troubles that is an unbroken made up word of a
length to your requirements, the whole col will be forced to accommodate
it. Thus if you have "123456789" in one cell in a col, then other cells
with "1 2" and "1 2 3" and "1 2 3 4" will not wrap the numbers because
"123456789" is holding the col open.

Or use a 55px wide clear gif and don't tell anyone.

--
dorayme

Posted by ilya2 on March 31, 2008, 1:24 pm
Please log in for more thread options
> Or use a 55px wide clear gif and don't tell anyone.

I was thinking of doing just that -- in the unused bottom row.

Posted by Ben C on March 31, 2008, 4:56 pm
Please log in for more thread options
> In article
> ilya2@rcn.com wrote:
>
>> I am making an HTML table. It has a lot of columns with fixed width
>> (55 pixels). If I view it on full-screen IE window, the table fits on
>> the screen and looks just as I want it to look. When I make the window
>> smaller than the table, I expect horizontal scroll bar to appear.
>> Instead each column shrinks; a cell which had:
>>
>> word1 word2
>> word3
>>
>> becomes:
>>
>> word1
>> word2
>> word3
>>
>> thus distorting the table and making it look ugly. Only when I make
>> the window so small that columns can not shrink any more (each is the
>> longest word wide), does horizontal scroll bar appear.
>>
>> How can I avoid this -- keep the columns same width regardless of
>> window size? I already tried giving the table a fixed width -- it does
>> not solve the problem, if anything makes it worse.
>
> If you fix width all the cells and all the same and in pixels, you do
> run into all sorts of problems; what would you want to happen, for
> example, if the user upped his text size, where is the text to go if it
> cannot fit?

Unless you use table-layout: fixed, it will fit, no matter how narrow
the cells are made.

> Everything depends on the details of your project, perhaps a url might
> help. But perhaps this will give you a thought to play with: Don't
> bother with giving the table itself a width, try min-width in em for
> either all the cells or selected cells (by classing them is most
> reliable). Choose a size to fit the point below which text will wrap to
> your displeasure:
>
> td {border: 1px solid; min-width: 20em;}

Width on table cells kind of means minimum width anyway.

[...]
> Or use a 55px wide clear gif and don't tell anyone.

I'm surprised setting a width on the whole table didn't work as intended
but then the OP is talking about IE where anything goes.

Posted by dorayme on March 31, 2008, 8:48 pm
Please log in for more thread options


> > Everything depends on the details of your project, perhaps a url might
> > help. But perhaps this will give you a thought to play with: Don't
> > bother with giving the table itself a width, try min-width in em for
> > either all the cells or selected cells (by classing them is most
> > reliable). Choose a size to fit the point below which text will wrap to
> > your displeasure:
> >
> > td {border: 1px solid; min-width: 20em;}
>
> Width on table cells kind of means minimum width anyway.
>
> [...]

Safari 2 is different to Firefox in the effects.

A table with td {border: 1px solid; width: 200px;} behaves differently
in different browsers to td {border: 1px solid; min-width: 200px;}

> > Or use a 55px wide clear gif and don't tell anyone.
>
> I'm surprised setting a width on the whole table didn't work as intended
> but then the OP is talking about IE where anything goes.

I am not sure he tried this? I know I did not (slaps forehead!) but it
might have been 3 or 4am in the morning here! Not being able to sleep
might not *quite* mean I am awake.

--
dorayme

Similar ThreadsPosted
window size ??? November 10, 2004, 7:23 am
Window size ramifications November 11, 2007, 8:39 pm
size attribute of input element: characters not fixed width? January 30, 2005, 7:26 pm
Table Within Table with colspan and width=100% August 15, 2005, 10:41 am
Problem with table width? July 19, 2004, 10:45 pm
TABLE, cell width.. help January 5, 2005, 9:52 am
Problem with TABLE WIDTH January 5, 2005, 6:53 pm
Problem with table 100% width June 8, 2005, 8:18 am
Controlling table width February 27, 2007, 7:33 am
table cell size July 21, 2004, 2:50 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap