TD WIDTH

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

TD WIDTH

Post by mjseaden »

Dear All,

I'm trying to get my TD elements to stick at a certain width - however because the TD is sometimes populated with text that is longer in pixel length than the stated WIDTH of the TD, the TD automatically resizes to fit the text. I don't want it to do this - rather I would like the text to be 'wrapped' around the size of the cell whilst the cell is kept at the stated width.

Is there any way of doing this?

Many thanks

Mark
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

You can either use php to check the string length and then cut the string up into new lines or you can use the overflow: scroll in CSS.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

TD is HTML. HTML is Client-Side.

Post moved to Client-Side forum.
User avatar
johnperkins21
Forum Contributor
Posts: 140
Joined: Mon Oct 27, 2003 4:57 pm

Post by johnperkins21 »

Do you have an example of code that isn't working? This should work:

Code: Select all

<table width="200">
<tr>
<td width="100">A whole buttload of text... blah, blah</td>
<td width="100">A whole buttload more text... blah, blah</td>
</tr>
</table>
If you have one really really long string, like trying to put posting.php?mode=reply&t=23778 into a TD tthat isn't big enough for it, it may try to resize your TD on you. If all else fails try:

Code: Select all

<table width="200">
<tr>
<td width="100" style="word-wrap: break-word;">A whole buttload of text... blah, blah</td>
<td width="100" style="word-wrap: break-word;">A whole buttload more text... blah, blah</td>
</tr>
</table>
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

patrikG wrote:TD is HTML. HTML is Client-Side.

Post moved to Client-Side forum.
gotta admire the simplicity of that post. :wink:
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

malcolmboston wrote:gotta admire the simplicity of that post. :wink:
/cackle :lol:
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

johnperkins21 wrote:Do you have an example of code that isn't working? This should work:
He might mean something like:
thisisanextremelylongwordthattakesupmorethanthetdwidth
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

If you have one really really long string, like trying to put posting.php?mode=reply&t=23778
I think thats what he meant with this.
User avatar
johnperkins21
Forum Contributor
Posts: 140
Joined: Mon Oct 27, 2003 4:57 pm

Post by johnperkins21 »

Ok, I just tested that whole style="word-wrap: break-word;" nonsense. It works in IE 6, but not in Firefox. Your next option is to use PHP, unless someone else knows of anything.

Try here: http://us4.php.net/wordwrap
Post Reply