简体   繁体   中英

Using css in a StringTemplate Email

I'm currently using StringTemplate to create my emails on the fly and its proven very easy to use in creation of the email. However, I'm trying to apply some styling to my emails and dont seem able to do this in the normal manner.

I can style parts of the mail if I write it inline, eg.

<p style="color:red;">Hello again, $name$ !</p>

will print the message in a red text.

But if I express a class like the following in my template:

<html>
<head>
   <title>Notification</title>       
</head>
<style>
    .myClass {
        text-decoration:underline;
           color:blue;
    }
   </style>
<body>      
    <p style="color:red;">Hello again, $name$ !</p>
    <p class="myClass">Here is your daily update</p>



   </body>
</html>

The paragraph with the "myClass" class isn't outputted in blue with an underline. I've tried importing stylesheets also but this didn't work.

Any help much appreciated,

-gearoid.

UPDATE: Looks at though it could be a gmail issue. If I view the mail on my iPhone it displays as expected...looks as though it'll have to all be done inline :(

Useful for future reference: http://www.campaignmonitor.com/css/

Please by wary of using stylesheets in your email templates as many email clients strip all content from the <HEAD> and simply display anything inside the <BODY> tags.

For this reason it is recommended that you use inline CSS only for complete cross-platform compliance.

Especially Firefox can be picky about content type. Try

<style type="text/css">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM