Solved

Wrapping text inside TD tag

Posted on 2004-09-07
11
11,699 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML Lists 3 45
Javascript create file issue 4 45
Form with Modals 16 42
How can I started with all items collapsed when using Nested Sortable ? 4 16
Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
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…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

919 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

14 Experts available now in Live!

Get 1:1 Help Now