Add inline CSS to your web version, unsubscribe and forward to a friend links

If you're used to coding your email newsletters for Gmail, you're probably an expert on inline CSS by now. As our recent CSS research highlighted, Gmail doesn't support the <style> or <link> element. This means if you want your links to be in a size 11 font and a light blue color, you'll need to code something like...

<a href="http://www.campaignmonitor.com" style="font-size:11px;color:#4fb5e9;">Visit the web site</a> to find out more

OK, kind of annoying but it works. But what about our automatically generated links for unsubscribing, linking to a web-based version and adding a forward to a friend link. As you know, these are generated after you import your design from the tags present in your HTML, such as <unsubscribe> and <webversion> and up until now you couldn't add your own inline CSS to them. Well, not until today anyway.

Introducing the style="" attribute

By adding a style="" attribute to the unsubscribe, webversion and forward a friend tags, we'll automatically add that inline CSS to the personalized links we create for each recipient.

Using our example above, let's say we want to make our unsubscribe link at the bottom of the email blue and in size 11 font.

<unsubscribe style="font-size:11px;color:#4fb5e9;">Unsubscribe</unsubscribe> from our monthly newsletter list

We'd get <a href="http://www.unsubscribeaddress.com" style="font-size:11px; color:#4fb5e9;">Unsubscribe</a> from our monthly newsletter list

You can use exactly the same technique for the web version and forward to a friend tags too, such as <forwardtoafriend style=""></forwardtoafriend> and <webversion style=""></webversion>.

Posted in:

17 Comments

  1. Funnily enough our designer discovered this was working last week ;)

  2. Nice spotting James, at least that proves the syntax we went for made sense ;)

  3. Campaign Monitor team member

    It’s amazing how Campaign Monitor constantly evolves to improve the lives of web designers. How did we get along without you?

  4. This isn’t working for me. I keep getting an error when trying to upload a template with this article’s suggestion.

  5. hcabbos, just to clarify, are you trying this with Campaign Monitor or MailBuild? This functionality is available in CM right now, but isn’t be in MailBuild just yet.

  6. Awesome feature! Any idea when this wil be available in MailBuild?!?

  7. Cheers Tracy, it’s in our schedule and should make its way in there in the next month or so. We’ll post it in the MailBuild blog when that’s the case.

  8. Would it be possible to off load even more of the work on CM?  If there was a way to define styles in the head (or body) and have them automatically convert into inline style declarations it would be incredible.

    Even if the styles didn’t cascade, just copying classes into inline declarations would make coding mailout templates so much easier.

  9. Automatic inline CSS would be the answer to my prayers, too. Right now I use a different service for a non-profit client who once a year over a week and a half has to send a unique newsletter to 50,000 emails every day - Campaign Monitor costs, even with the bulk rate, are prohibitive at that scale. However, if Campaign Monitor implemented something like this it might just save me enough time in development to offset the cost difference. I love Campaign Monitor and wish I could use it for every client - you guys are the Rolls Royce of email campaigns. :)

  10. Instead of whining to Campaign Monitor, I decided to go to the source. I don’t really want easier creation of inline styles, I want Google to support style declarations in the head of HTML emails! Turns out their is a form to request it as a feature! Maybe if we get loads of designers requesting it, it will actually happen. I don’t know about you, but I have more problems supporting Gmail than any other email service.

    https://services.google.com/inquiry/gmail_suggest/

    Here is what I wrote under “I have a better idea:”

    SUPPORT CSS STYLE DECLARATIONS IN THE HEAD OF HTML EMAILS!

    I have to add significant extra hours to every email design project in order to take all my nicely separated styles in my nicely standards-compliant HTML prototype and then bloat my code by stuffing all those styles inline—just so that my gmail subscribers can see the same thing the rest of the standards compliant world sees. Not only is this bandwidth wasting for the world and more expensive (in terms of hours spent) to me and my clients, it makes me think very poorly of Google as I go through this soul sucking, professionally demeaning exercise.

    Please support css style declarations in the head of HTML emails. Why can’t gmail support an email with style and content elegantly separated? Why is this standard of the web dismissed?

    PLEASE PLEASE PLEASE.

  11. I took my own advice and created a script to make styles inline - see <a href=“http://code.dunae.ca/premailer.web/” rel=“nofollow”>http://code.dunae.ca/premailer.web/</a>.

    The script takes any HTML document, reads all of its external styles and merges them into style=”” attributes.

    It also converts relative links (/images/img.jpg) into absolute paths (http://example.com/images/img.jpg).

    I can now, finally, design a newsletter without pulling out my hair.

  12. Awesome move Alex, great work. We’ll make sure we post about this in the blog real soon.

  13. Is this feature already available in MailBuild. I got an error uploading a template with these settings.

    The month has already passed! ;-)

  14. I also can’t wait for this feature to be implemented in MailBuild.  That will truly make it the perfect HTML e-mail builder.

  15. Yeah, i need it in Mailbuild! i hate Gmail!

  16. http://index1.yourgunter.com >sensual female nudes

  17. Hello,

    Any update about an implementation of this feature into MailBuild?

    It is a must for me. Without that, unsubscribe/forward/webversion links are awfully displayed into Gmail.

    Best,
    Thomas.

Comments for this entry are closed.

Explore the Email Gallery

“How We’re Hacking Email at @HubSpot” - great code tips here from @hijonathan! http://t.co/L9QGsdjA ^RH

Follow us on Twitter