user690986
user690986

Reputation: 41

How to break a long text in a <td> table cell?

I am using that CSS for TD:

table.grid td {
border:1px solid #E6E6E6;
font-size:14px;
padding:5px 5px 5px 14px;
}

Upvotes: 0

Views: 5811

Answers (3)

GuyFromOverThere
GuyFromOverThere

Reputation: 471

pre {
    white-space: pre;           /* CSS 2.0 */
    white-space: pre-wrap;      /* CSS 2.1 */
    white-space: pre-line;      /* CSS 3.0 */
    white-space: -pre-wrap;     /* Opera 4-6 */
    white-space: -o-pre-wrap;   /* Opera 7 */
    white-space: -moz-pre-wrap; /* Mozilla */
    white-space: -hp-pre-wrap;  /* HP Printers */
    word-wrap: break-word;      /* IE 5+ */
}

wrap the pre around your text and it should work

Upvotes: 2

Marcus
Marcus

Reputation: 5143

By default table cells stretch to fit the content. If you give them a fixed width, they will force the content to fit that width. This assumes you can say what would be a good width for them. In non-IE6 world you can also use attributes max-width and min-width.

Example:

.grid td       {max-width: 200px;}
.ie6 .grid td  {width: 200px;}

Upvotes: 2

nanda kumar
nanda kumar

Reputation: 31

use white spacing for break your data like wrap and no wrap

table.grid td {
   border      : 1px solid #E6E6E6;
   font-size   : 14px;
   padding     : 5px 5px 5px 14px;
   white-space : wrap;
}

Upvotes: 1

Related Questions