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!
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.


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

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!

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.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
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…

691 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