Solved

Table Cell Wrapping

Posted on 2000-04-18
7
1,035 Views
Last Modified: 2008-02-26
I have a table with width = 485

and a table cell also with witdth = 485

When i add a string which consits of text with spaces to the cell the cell is auto nmtically wrapped. But if i add a lengthy sting without spaces, my table cells does'nt wrap instead it expands to the length of the string irrespective of the table cell width.

How do i make the string wrap.

Thanks in advance.
0
Comment
Question by:LotsOfQuestions
7 Comments
 
LVL 8

Expert Comment

by:xabi
ID: 2727208
You can't do that.

xabi
0
 
LVL 3

Expert Comment

by:fibdev
ID: 2727531
Try using percentages in your table and cell widths.
0
 
LVL 2

Expert Comment

by:freshmeat
ID: 2729118
it is very headache!
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 3

Expert Comment

by:TEFKASG
ID: 2729509
Unfortunately I must agree with xabi.  In html, as far as I know, there is no way to do what you want, and I have looked for this exact result/behavior.
  The only way I know to do this, is to parse the string, and insert a break(newline, or some character that will allow the string to wrap) into the string after a specified number of characters, using some programming language, like C++(not your only choice).
  If you somehow find a solution using only HTML, please post it here as I would dearly like to know what it is.
0
 
LVL 3

Expert Comment

by:TEFKASG
ID: 2729524
One way to limit the effect is to break your table cells into individual tables, not contained in a single overall table.  This way, only the cell containing the long string is elongated and the rest of the tables-cells are unaffected.   Not a perfect solution, and not feasible in all cases, but it helps minimize the effect.
0
 
LVL 7

Expert Comment

by:nettrom
ID: 2730020
xabi's answer is correct here.  HTML (and CSS) have only properties for setting the content to not wrap.  it's fairly logical.  if you have a laaaaaarge string, how should the browser know where to wrap it?
0
 

Accepted Solution

by:
epoulsen earned 50 total points
ID: 2737679
You can use Javascript to chop up the text for you.  If possible, wrap your text inside a function that will take the string, insert line feeds (according to a stopLength that you determine), and return a new, wrapped string.

Here's an example:

<HTML>
<HEAD>
<SCRIPT>
function parseString(theString) {
  var stopLength = 10; // the length at which you want your string to wrap
  var theReturnString = "";

  for ( i = 0 ; i < theString.length ; i++) {
      theReturnString += theString.charAt(i);
//      alert("theReturnString is " + theReturnString);
      if (i > 0 && (i + 1) % stopLength == 0) {
            theReturnString += "\n";
      }
  }

  document.write(theReturnString);
  document.close();
}
</script>
</head>
<body>
<table width=10>
<tr>
<td><script>parseString("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 10)</script>
</td>
</tr>
</table>
</body>
</html>

If the table width is dynamic, you can pass in a second argument with whatever stopLength you wish.

Good Luck,

Esther
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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

920 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

11 Experts available now in Live!

Get 1:1 Help Now