Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to break long words in a table td?

This is what I have:

<td style='width:500px; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;'>

like image 897
GuyFromOverThere Avatar asked Sep 02 '11 14:09

GuyFromOverThere


People also ask

How do you break a long word in CSS?

The word-break property in CSS is used to specify how a word should be broken or split when reaching the end of a line. The word-wrap property is used to split/break long words and wrap them into the next line. word-break: break-all; It is used to break the words at any character to prevent overflow.

How do you wrap text in a table cell?

Solution with the CSS word-wrap propertyUse the border-collapse property set to "collapse" and table-layout property set to "fixed" on the <table> element. Also, specify the width of the table. Then, set the word-wrap property to its "break-word" value for <td> elements and add border and width to them.


1 Answers

I used:

word-wrap: break-word;
word-break: break-all;
table-layout: fixed;

table-layout: fixed was the key to making it work.

like image 123
Steve Avatar answered Sep 24 '22 20:09

Steve