I have a table which has a long line in one of its cells. I need the long line to be split so that it doesn't cause the table to be more than 100% wide. I found that by adding table-layout: fixed
and word-wrap: word-break
, it will wrap the long cell. However, a side effect of using table-layout
is that it causes all columns to have the same width.
You can see an example of that here:
How can I make the first column's width auto size to fit only its contents? (i.e. In this example, it should be just wide enough to show the 1
and 2
in that column.)
The data in the table will be loaded dynamically, so a solution which hard codes width values is not good because there's no way to know in advance how wide a column should be. My only option is to use a <table>
, I can't use a <div>
or some other element.