0

I have a table with width of 250 px, I am creating this table using a stringbuilder, but when I add long strings to table data, the data renders as one long line, it does not stay in table.

When I use firebug I see that the table is 250 px, but data does not wrap within it.

Help pls! thanks!

EDIT: was using whitespace:nowrap; from another CSS which was messing it all up. thx for help

aolle
  • 1
  • 2
  • Yes, I was mystified at your result, because I built a table with a stringbuilder and it wrapped just fine. Glad to see you found your error. As a newcomer to Stackoverflow, you should know that in such a case you would enter your answer as an answer, then Accept it. This gives some sort of closure, and gets you a badge and some reputation points. Just sayin' ! – Cyberherbalist Aug 05 '10 at 16:03

2 Answers2

1

You can prevent a table from expanding for long strings by giving it the style table-layout: fixed.

kbrimington
  • 25,142
  • 5
  • 62
  • 74
  • thanks but as I mentioned and verified with firebug the table itself is not expanding and is rendering at 250px. the text in the however, is running way past the right border – aolle Aug 05 '10 at 15:43
  • 1
    @aolle: Firebug tells you how the cell is styled. Clearly the cell is not actually 250px wide. Tables will flex unless explicitly told not to. – kbrimington Aug 05 '10 at 15:51
0

Couple of things that you may try:

  1. Inject a style into the td that is behaving bad: style="word-wrap:break-word;"
  2. Check out the following to see if it helps: Word-wrap in an HTML table

Hope it helps!

Community
  • 1
  • 1
Vaibhav
  • 1,156
  • 2
  • 12
  • 27