I have the following code:
<table style="width: 100%; max-width: 800px; table-layout: fixed;">
... table stuff here ...
</table>
I think it’s obvious I intend for the table to take the full width available, with a capped maximum size of 800px.
This works in Internet Explorer and Firefox, however in Chrome it appears that the max-width is being ignored when width is present.
I have tried using max-width: 100%; width: 800px;, which again works in IE and FF but the max-width is ignored in Chrome. I have tried using just max-width: 800px but in Chrome the table comes out 1159 pixels wide instead… !
If anyone can help with this, it would be much appreciated.
Add
to the table element’s
styleattribute (preferably in a CSS file or the<style>section of the document rather than as in inline style).<div>elements havedisplay: blockby default, while<table>elements havedisplay: table;by default. Your problem is that themax-widthproperty only applies to block elements, so you have to applydisplay: block;to the table.