Solved

Wrapping text inside TD tag

Posted on 2004-09-07
11
11,697 Views
Last Modified: 2010-05-18
Hi,

   I have a table where I have sepcified width for all columns. When I add a text of more than 30 chars, the column instead of wrapping the text, it expands. It behaves as though I have given nowrap for the TD. Is there any way I can make the text wrap once it is exceeding the specified width given to the column.

Thank you
0
Comment
Question by:gops1
  • 3
  • 2
  • 2
  • +4
11 Comments
 
LVL 8

Expert Comment

by:RozanaZ
ID: 12003758
Why don't you remove nowrap from TD?
0
 
LVL 17

Author Comment

by:gops1
ID: 12003797
Rozana,

I have not used nowrap. I meant when i put some text without any space the TD BEHAVES like a TD with nowrap.

Gops
0
 
LVL 2

Expert Comment

by:ecupd
ID: 12003980
Hi Gops,

paste your code, it sounds like there is no width value given to the <table> tag.
with table widths set a TD should eventually wrap always

Is there any content in any of the TD's in that column that hold it at a particular min width at the moment?

dayton
0
 
LVL 4

Expert Comment

by:samscudder
ID: 12005037
If it's just one word it will expand the column. In IE, there is the "word-wrap" style, but I´m not sure about other browsers:

<table border=1>
<tr>
<td width=50 style="word-wrap: break-word">OneLongWordWhichWillBeBroken</td>
</tr>
</table>

Hope this helps

S
0
 
LVL 31

Expert Comment

by:seanpowell
ID: 12005231
You may need to add this to Sam's last post:

<table ........  style="table-layout:fixed;">

Thanks,
Sean
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 40 total points
ID: 12008979
Using non-standard thing like word-wrap is a bad idea.  All you do is create a fundemental design defect in non-IE browsers; definitely not a good idea at the rate IE is losing market share.

table-layout:fixed will resolve the expanding cell problem, but will create a new one.  IE by default will hide the overflow(truncate it) but Mozilla will render it outside the box. so overflow needs to be use to control the dispositon of the excess:

<td width=50 style="overflow:hidden;clip:auto">OneLongWordWhichWillBeBroken</td>
or
<td width=50 style="overflow:auto;clip:auto">OneLongWordWhichWillBeBroken</td>

are standards compliant, and will continue to work after IE is forced to follow the standards, and get rid of the proprietary bloat to stay competitive.

Cd&
0
 
LVL 5

Assisted Solution

by:KarcOrigin
KarcOrigin earned 20 total points
ID: 12012413
Hmmm...doesn't work

<Table width="100%">
<TR>
  <TD width="25%" style="overflow:auto;clip:auto">TextboxTextboxTextboxTextboxTextboxTextboxTextboxTextboxTextboxTextbox</TD>
  <TD width="75%"><INPUT id="txtBox" name="txtBox" value="Test value"></TD>
</TR>
</Table>

But gops1 COBOLdinosaur is write. I also don't think it is a good idea to be specific to only one browser. If you are getting the continous string then better break it with a single spaces.

Cheers!

0
 
LVL 17

Author Comment

by:gops1
ID: 12013191
Thanks a lot COBOLdinosaur and Karc.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12016388
Glad we could help.  Thanks for the A. :^)

Cd&
0
 
LVL 31

Expert Comment

by:seanpowell
ID: 12016444
... and thank you Cd& for pointing out the proprietary MS code - I keep forgetting what's part of the official spec and what isn't.
That cave wall must come in pretty handy :-)
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12018992
I keep running up against the IE only stuff all the time trying to migrate apps to support Mozilla.  It hard to believe some of the stuff we used to do because we were in an IE environment.  Fortunately .net is pretty much a dead issue so I don't have to fight that off... at least in the technology division.  Corporate is another story.  They think the world revolves around activex. :^(

Cd&
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now