Repurpose your Images for Mobile Email |
|
10.19.2011 Get connected with Email on Acid for up-to-date news and information on the subject of email design, development, and testing! |
By John ThiesFebruary 10, 2011 |
The Android Mail App and CSS “Class” DeclarationsWhile testing the native Android email application we found that it does not support embedded or linked CSS class declarations. For example, the following CSS declaration will not be displayed within the mail application: .test { background-color: red}
This may not be a major issue since its better to use inline CSS wherever possible but we found a work around just in case you have no choice but to use some embedded CSS in your HTML email. We discovered this solution while testing the @media query support on the Android device. As it turns out - if you wrap a CSS class declaration within a "@media all" block it will render the CSS. Here is an example: @media all { .test {background-color: red; } }
The great thing about this work-around is that the "@media all" CSS block is supported in every email client that currently supports embedded CSS (argh Gmail!). To get the best intended display results, wrap all of your embedded class declarations within a @media query block. I also tested this fix for linked CSS. Although linked style sheets are not recommended for all email clients, it will work for the native Android email application. All you need to do is include the "media" attribute with a value of "all" like this example: <link rel="stylesheet" media="all" href="http://www.domain.com/example.css" />
So from now on remember to wrap all your embedded CSS within a media query block (@media all) and include the "media" attribute in linked CSS tags. That way all of your CSS class declarations will be rendered, barring you don't have any unsupported CSS properties within the declaration.
|
If you haven't signed up yet, give our FREE online Email Test a try. Just drop in your code and we will instantly simulate your email in the most popular email clients!
Get connected with Email on Acid for up-to-date news and information on the subject of email design, development, and testing!
I'm not having much luck. I'm trying to show/hide desktop and smartphone versions of content using these things, and this code doesn't work for me in Gmail web, Gmail Android, or the Android Email client:
<style type="text/css">
@media all {
p#desktop {display:none !important;}
p#smartphone {display:block !important;}
}
</style>
Combining it with a media query, then, also did not work:
<style type="text/css">
@media all and (max-device-width: 480px) {
p#desktop {display:none !important;}
p#smartphone {display:block !important;}
}
</style>
In Android Email, I see nothing (even without those styles) making me think my company's HTML email is just bad on the Android client.
In Gmail on web and the Android Gmail client, those rules appear to just be ignored.
Any thoughts? See anything I'm doing wrong there?
Porter