Most of solutions use static width here. But it can be sometimes wrong for some reasons.
Example: I had table with many columns. Most of them are narrow (static width). But the main column should be as wide as possible (depends on screen size).
HTML:
<table style="width: 100%"> <tr> <td style="width: 60px;">narrow</td> <td> <span class="cutwrap" data-cutwrap="dynamic column can have really long text which can be wrapped on two rows, but we just need not wrapped texts using as much space as possible"> dynamic column can have really long text which can be wrapped on two rows but we just need not wrapped texts using as much space as possible </span> </td> </tr> </table>
CSS:
.cutwrap { position: relative; overflow: hidden; display: block; width: 100%; height: 18px; white-space: normal; color: transparent !important; } .cutwrap::selection { color: transparent !important; } .cutwrap:before { content: attr(data-cutwrap); position: absolute; left: 0; right: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #333; } /* different styles for links */ a.cutwrap:before { text-decoration: underline; color: #05c; }