Table Cell Wrapping

Posted on 2000-04-18
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.
Question by:LotsOfQuestions
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 2727208
You can't do that.


Expert Comment

ID: 2727531
Try using percentages in your table and cell widths.

Expert Comment

ID: 2729118
it is very headache!
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

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.

Expert Comment

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.

Expert Comment

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?

Accepted Solution

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:

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";

<table width=10>
<td><script>parseString("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 10)</script>

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

Good Luck,


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add a Location and Color Price based on select box selected option 17 66
send email part1 9 40
CSS Style 8 43
how to customize the text in the legend in highcharts 3 35
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.
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 …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

726 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