I have an HTML table in which one particular cell can have long text (up to a paragraph). Is there a way to change the way text wraps in that cell so that if it is long enough to stretch the table horizontally it instead wraps and possibly stretches the table vertically? I want the width of the column to be determined dynamically by the rest of the cells in the column as it would be if there was no text in that cell.
Clarification: I want the width of the cell with potentially long text to be determined entirely by the widths of the other cells in the columns, with the text in it wrapped to fit within that width. I do not want to have a static column width or max column width because the page is generated dynamically with data from a database.
Example:
<table>
<tr><td>Test Test Test</td></tr>
<tr><td class="X">Test Test Test Test Test Test Test Test Test</td>
</table>
Where "X"
denotes the cell that should wrap when possible
The default behavior is
|--------------------------------------------|
|Test Test Test Test |
|--------------------------------------------|
|Test Test Test Test Test Test Test Test Test|
|--------------------------------------------|
I want it to instead do
|-------------------|
|Test Test Test Test|
|-------------------|
|Test Test Test Test|
|Test Test Test Test|
|Test |
|-------------------|
Even if this is smaller than the width of the screen. I am wondering if it is possible to do this without knowing the width of any of the text when I create the table.
I solved this by setting the width to one pixel in the table cell I wanted to have forced word wrap.