This fantastic article describes how to create responsive tables which scale fabulously to mobile browsers.
Now I'm trying to apply the same technique to html emails but display:block
just won't seem to work in html emails.
To reproduce the issue:
Save the following code as an HTML page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta charset="utf-8"> <style type="text/css"> @media only screen and (max-width: 760px), screen and (max-device-width: 480px) { /* Force table to not be like tables anymore */ table, td, tbody, tr{ display: block; width:100%; padding:0; clear:both; } td { /* Behave like a "row" */ position: relative !important; } } </style> </head> <body> <table style="width:100%;"> <tr> <td style="border:1px solid red;">1/1</td> <td style="border:1px solid red;">1/2</td> <td style="border:1px solid red;">1/3</td> </tr> <tr> <td style="border:1px solid red;">2/1</td> <td style="border:1px solid red;">2/2</td> <td style="border:1px solid red;">2/3</td> </tr> </table> </body> </html>
Open the page in Safari
Resize the window to note how the table changes with a smaller window-size
Press CMD+i or
File->Mail
Contents of this page to create a HTML emailResize the email window to note how the table still resizes correctly
Send the email to yourself and open it.
Now notice how the email indeed responds to the media query but unsuccessfully restyles the table.
I have yet to find an email client that actually displays the table correctly. Is this a dead-end or do you have ideas of workarounds?