How can I set the max-width of a table cell using percentages?

Leo Jiang picture Leo Jiang · Dec 11, 2011 · Viewed 194.7k times · Source
<table>
<tr>
<td>Test</td>
<td>A long string blah blah blah</td>
</tr>
</table>

<style>
td{max-width:67%;}
</style>

The above does not work. How can I set the max-width of a table cell using percentages?

Answer

superphonic picture superphonic · May 5, 2015

Old question I know, but this is now possible using the css property table-layout: fixed on the table tag. Answer below from this question CSS percentage width and text-overflow in a table cell

This is easily done by using table-layout: fixed, but a little tricky because not many people know about this CSS property.

table {
  width: 100%;
  table-layout: fixed;
}

See it in action at the updated fiddle here: http://jsfiddle.net/Fm5bM/4/