Solved

Table Cell Wrapping

Posted on 2000-04-18
7
1,034 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

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

13 Experts available now in Live!

Get 1:1 Help Now