Creative Uses of Tables: Maximum Width

Usually, we might use the CSS 'max-width' property to set a maximum width for an element, which works well and is even compatible with IE7.

However, I prefer to use table elements, just like on this page (and most pages on my website). This approach not only allows the element to reach its maximum width when the viewport is wide enough, but also automatically fills the available width when it isn't — and it's even compatible with IE6!

 

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<table style="margin: 0 auto;"><!-- Center alignment -->
  <tr>
    <td style="width: 64em;"><!-- Maximum width: 64em -->
      Content
    </td>
  </tr>
</table>