Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Forcing table width

Reply
Thread Tools

Forcing table width

 
 
John Wood
Guest
Posts: n/a
 
      04-15-2004
I've noticed that a table cell width is ignored if the content contains
words that (themselves) are wider than the specified width. The table just
grows width-wise.

Is there any way to stop this?

I'm trying to get my tables to fit 640px wide, but the content frequently
makes them bleed off the page.

TIA,
John


 
Reply With Quote
 
 
 
 
The Doormouse
Guest
Posts: n/a
 
      04-15-2004
"John Wood" <> wrote:

> Is there any way to stop this?


CSS might do it.

The Doormouse

--
The Doormouse cannot be reached by e-mail without her permission.
 
Reply With Quote
 
 
 
 
Barry Pearson
Guest
Posts: n/a
 
      04-15-2004
John Wood wrote:
> I've noticed that a table cell width is ignored if the content
> contains words that (themselves) are wider than the specified width.
> The table just grows width-wise.
>
> Is there any way to stop this?
>
> I'm trying to get my tables to fit 640px wide, but the content
> frequently makes them bleed off the page.


Wrap the content of those cells into a <div>, then control the <div> via CSS.

<td>
<div class="something">
stuff goes here
</div>
</td>

div.something {
width: 200px;
height: 300px;
overflow: auto;
}

Tables are wonderfully flexible, adapting to the user's environment such as
text size & viewport width. This is fully within the spirit of the web, with
fluid design conforming to the needs and preferences of the users.

But sometimes this is a problem for authors. So don't try to control the
tables directly. You can't. Control their content instead. Then the table will
adapt to the controlled content. If you wrap the content in a <div>, and
control the <div>, the table will adapt, and the <div> will shield the table
from its contents.

In the above CSS, the { overflow: auto } will give scrollbars *if needed*.
Alternatively, you could use { overflow: hidden } and hide the extra stuff.

--
Barry Pearson
http://www.Barry.Pearson.name/photography/
http://www.BirdsAndAnimals.info/
http://www.ChildSupportAnalysis.co.uk/


 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      04-15-2004
Barry Pearson wrote:

> John Wood wrote:
>> I've noticed that a table cell width is ignored if the content
>> contains words that (themselves) are wider than the specified width.
>> The table just grows width-wise.
>>
>> Is there any way to stop this?
>>
>> I'm trying to get my tables to fit 640px wide, but the content
>> frequently makes them bleed off the page.


Why not reduce the content then?

> Wrap the content of those cells into a <div>, then control the <div> via
> CSS.
>
> <td>
> <div class="something">
> stuff goes here
> </div>
> </td>
>
> div.something {
> width: 200px;
> height: 300px;
> overflow: auto;
> }


Why not apply the CSS directly to the table data cell?


--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
 
Reply With Quote
 
Barry Pearson
Guest
Posts: n/a
 
      04-15-2004
David Dorward wrote:
> Barry Pearson wrote:
>> John Wood wrote:
>>> I've noticed that a table cell width is ignored if the content
>>> contains words that (themselves) are wider than the specified width.
>>> The table just grows width-wise.
>>>
>>> Is there any way to stop this?
>>>
>>> I'm trying to get my tables to fit 640px wide, but the content
>>> frequently makes them bleed off the page.

>
> Why not reduce the content then?


The size of the content is often not under the control of the author. Tables
are wonderfully flexible, adapting to the user's environment such as text size
& viewport width. This is fully within the spirit of the web, with fluid
design conforming to the needs and preferences of the users.

But the layout concept may want control of the width and/or height. At least
for some cells.

>> Wrap the content of those cells into a <div>, then control the <div>
>> via CSS.
>>
>> <td>
>> <div class="something">
>> stuff goes here
>> </div>
>> </td>
>>
>> div.something {
>> width: 200px;
>> height: 300px;
>> overflow: auto;
>> }

>
> Why not apply the CSS directly to the table data cell?


See above. It doesn't work. Tables typically override CSS controls. Tables
adapt to their content. So control their content instead.

Experiment. Compare controlling table cells with controlling the contents of
tables cells. The difference is amazing.

--
Barry Pearson
http://www.Barry.Pearson.name/photography/
http://www.BirdsAndAnimals.info/
http://www.ChildSupportAnalysis.co.uk/


 
Reply With Quote
 
John Wood
Guest
Posts: n/a
 
      04-16-2004
Actually controlling the content in this case is difficult. The table has
alternating spanning column rows containing a lot of text. If any of the
words are unable to wrap correctly, the table resizes... I could look
through all the text and put a maximum width on each word, but the overhead
of doing that may be too large. I'd rather put the processing overhead on
the client.

The div solution does work, but does slow down with larger tables... and I
have yet to see how it works in browsers such as Safari.

Thanks all for your suggestions!

"Barry Pearson" <> wrote in message
news:qbDfc.26$mQ3.11@newsfe1-win...
> David Dorward wrote:
> > Barry Pearson wrote:
> >> John Wood wrote:
> >>> I've noticed that a table cell width is ignored if the content
> >>> contains words that (themselves) are wider than the specified width.
> >>> The table just grows width-wise.
> >>>
> >>> Is there any way to stop this?
> >>>
> >>> I'm trying to get my tables to fit 640px wide, but the content
> >>> frequently makes them bleed off the page.

> >
> > Why not reduce the content then?

>
> The size of the content is often not under the control of the author.

Tables
> are wonderfully flexible, adapting to the user's environment such as text

size
> & viewport width. This is fully within the spirit of the web, with fluid
> design conforming to the needs and preferences of the users.
>
> But the layout concept may want control of the width and/or height. At

least
> for some cells.
>
> >> Wrap the content of those cells into a <div>, then control the <div>
> >> via CSS.
> >>
> >> <td>
> >> <div class="something">
> >> stuff goes here
> >> </div>
> >> </td>
> >>
> >> div.something {
> >> width: 200px;
> >> height: 300px;
> >> overflow: auto;
> >> }

> >
> > Why not apply the CSS directly to the table data cell?

>
> See above. It doesn't work. Tables typically override CSS controls. Tables
> adapt to their content. So control their content instead.
>
> Experiment. Compare controlling table cells with controlling the contents

of
> tables cells. The difference is amazing.
>
> --
> Barry Pearson
> http://www.Barry.Pearson.name/photography/
> http://www.BirdsAndAnimals.info/
> http://www.ChildSupportAnalysis.co.uk/
>
>



 
Reply With Quote
 
Mark Parnell
Guest
Posts: n/a
 
      04-19-2004
On Thu, 15 Apr 2004 18:07:35 GMT, "John Wood" <>
declared in alt.html:

> I'm trying to get my tables to fit 640px wide, but the content frequently
> makes them bleed off the page.


"Doctor, it hurts when I do this."
"Stop doing that."

http://www.allmyfaqs.com/faq.pl?AnySizeDesign
http://www.allmyfaqs.com/faq.pl?Tableless_layouts

--
Mark Parnell
http://www.clarkecomputers.com.au
 
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
Help! Fixed width table with a 100% width image in it is assuming theimages intrinsic size, although it does shrink the image satya.komatineni@gmail.com HTML 1 12-29-2007 08:32 PM
picture width decides table column width David Basford HTML 3 09-30-2007 10:49 PM
Textbox width scaling to width of data not width of page? AndrewF ASP .Net 1 10-10-2005 04:38 PM
Table width and columns width kris HTML 11 11-18-2003 06:49 AM
Re: resized image in table extends table width to original image width Sean Jorden HTML 1 08-19-2003 08:59 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57