Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wrap text in html table!

Status
Not open for further replies.

HollyVally

Programmer
Jan 3, 2003
48
BD
Hi all,

Sorry to ask a stupid question:

How can I wrap the text in a table cell(<TD></TD>)?
 
\n is a newline in javascript <br> is a newline in HTML


so some<br>text wil display as

some
text


Chris.

Indifference will be the downfall of mankind, but who cares?
 
eh how bout the obvious

<table>
<tr>
<td width=&quot;100&quot;>this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text</td>
<td>&nbsp</td>
</tr>
</table>

sometime you just gotta say &quot;WHAT THE @#*% !!&quot;
 
Hi Deecee,

Thanks for the advice. I am actualy trying the way you have shown in your example, without any luck.

My Idea was that if
Code:
<td width=&quot;100&quot;>
is written than after 100 chars or pixels or points will be in the same line, and the rest would go to the next line in the same cell!

But both (IE6 & NS7.1) browsers are showing really funny thing:

IE6: changes the width of the cell at will.
NS7.1: shows everything in one loooooong line.

any explanation for that!

Cheers!
 
Sorry...
I meant first instead I said after in ...
My Idea was that if
Code:
<td width=&quot;100&quot;>
is written than after 100 chars or pixels or points will be in the same line, and the rest would go to the next line in the same cell!

....Thanks
 
well in theory that's what should happen but as you're finding out the browsers are 'flexible' with your tables.
Is your <table> fixed width or %, have you any cells spanned across columns, any unbalanced tags? all these will mess with your layout.

This is where CSS wins, if you can get away from using tables for positioning and use <div> and a css class or id instead it will be far easier in the long run. your pages be cross browser compliant and much easier to change in the future.

Chris.



Indifference will be the downfall of mankind, but who cares?
 
Hi Chris,

Brilliant Idea! (using CSS)

But I have a very little and limited idea regarding implementing it. All I know that I can define the table tags in my way in a CSS and include the file in the HTML header!

I know this is NOT all about CSS -- what I don't know is how to get the quick workable *hunch* of CSS to do my trick without using table(*I hate it!*).

If you could guide me through a couple of steps in finding the source of info I would be highly obliged!

Cheers!
 
the table that has the width shouldnt expand...just add some content to the blank cell and it should work. this isnt really a complicated issue.

sometime you just gotta say &quot;WHAT THE @#*% !!&quot;
 
I think HollyVally want to find the wrap function like the HTML tag <TEXTAREA> does
e.g. <TEXTAREA cols=&quot;20&quot; rows=&quot;4&quot;>123456789012345678901234567890</TEXTAREA>
(automatically wrap the characters to 2nd line)
In <TD> we can use the css STYLE=&quot;word-wrap: break-word&quot; to wrap the text, but only IE5.5+ support it
e.g.
<TABLE width=&quot;300&quot; border=&quot;1&quot;>
<TR>
<TD width=&quot;150px&quot; style=&quot;word-wrap: break-word&quot;>123456789012345678901234567890</TD>
<TD width=&quot;150px&quot;>123456789012345678901234567890</TD>
</TR>
</TABLE>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top