I've observed a curiosity of how browsers (at least: Chrome, Firefox, and Safari) treat the max-width and width properties when applied to a table cell: if the cell contains a single huge word, then the width property will not be respected if it tries to set the cell's width to less than that required to contain the word.
That is, if I write this HTML, where the first table has a width of 100px and the second has a max-width of 100px and both contain a single huge word, then the first table renders really wide and the second gets constrained to 100px:
<style>
td {
border: 1px solid; /* To help visualisation */
word-wrap: break-word;
}
</style>
<table>
<tr>
<td style="width:100px">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</td>
</tr>
</table>
<table>
<tr>
<td style="max-width: 100px">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</td>
</tr>
</table>
Why is this the case? Should width be respected in this case? Is the difference in behaviour between width and max-width a browser bug, or is it somehow dictated by spec? A glance at the definitions of width and max-width in the CSS Level 2 spec and CSS Intrinsic & Extrinsic Sizing Module Level 3 (linked below) doesn't seem to immediately suggest any circumstances in which max-width should be respected but width disregarded; am I missing something?
Spec links:
