Kirk Ross
Kirk Ross

Reputation: 7153

How to make td characters wrap even if string is unbroken?

If I have a td with a long, unbroken string of text, how can I make the text start wrapping to the next line, character by character as you reduce the window width?

In this fiddle, adjust the output box width and it'll throw a scrollbar, but I'd like the text to start wrapping, char by char to the next line.

http://jsfiddle.net/kirkbross/mn6at1hg/

<table width="100%" border="1" cellpadding="10" cellspacing="0">
  <tr>
    <td align="right">Left td</td>
    <td align="left">ThisisawholebunchoftextIwanttowrapbasedonawidthevenifitdoesntbrea</td>
  </tr>
</table>

Upvotes: 0

Views: 435

Answers (1)

Stuart
Stuart

Reputation: 764

You can use:

table {
    table-layout: fixed;
}
td {
    word-wrap:break-word
}

The jsFiddle - https://jsfiddle.net/sleaver/tLd0g651/4/

Upvotes: 1

Related Questions