Here is what I use for html emails to hide and show content. Basic, user-friendly classes "mobile" and "desktop". Mobile is for mobile devices only. "Desktop" is displayed only for the desktop.
*[class=mobile]{display:none;} @media only screen and (max-width:600px) { *[class=desktop]{display:none !important;} *[class=mobile]{display:block !important;width:auto !important;max-height:inherit !important;overflow:visible !important;float:none !important;} *[class="block"]{display:block !important;padding:5px;} }
But if you want your email to work the way you hoped, in Outlook and Gmail you need to go a little further. These email clients will display the desktop version, regardless. But you donโt want them to display mobile content, so wrap all your mobile content in a conditional comment shown in the example below. This will cover you for Outlook.
To make Gmail behave, you need to zero out all of your elements and expand them into CSS, which Gmail completely ignores. All built-in which you do not want to show Gmail should be width: 0; max-height: 0; overflow: hidden;
This is when CSS (the example above comes into play). A second-class ad in a media query expands your block to a suitable size for display on mobile devices, and Gmail hides it.
<td class="mobile" style="width: 0;max-height: 0;overflow: hidden;"> <img alt="" border="0" src="http://www.placehold.it/150x150" style="display:block;" width="100%"> </td>
And last but not least, this last part has not yet been tested. I am having problems with Windows Mobile to hide what I want it to hide. I think developing my conditional comment will solve the problem by changing it like this:
<![if !IEMobile]> <td class="mobile" style="width: 0;max-height: 0;overflow: hidden;"> <img alt="" border="0" src="http://www.placehold.it/150x150" style="display:block;" width="100%"> <![endif]>
But then again, this last part, which I have not tested yet, will test tomorrow tomorrow, but if someone wants to develop Windows Mobile, please do it. I carefully checked everything else.