Solved

Table Cell Wrapping

Posted on 2000-04-18
7
1,038 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

792 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