Thinking » Tags » tips

J Hogue

Coding for Constant Contact

As designers get used to all the new whizz bang inherit in HTML5 and CSS3, every now and then we get pulled back into the world of basic HTML rendering a là 1993 when we have to design e-newsletters for desktop and web-based Mail clients.

I recently had to create some templates for Constant Contact and I thought, “Hey, this should be easy. Can’t do anything tricky, so, keep the design simple, use a tried-and-true table for the layout, and viola, beautiful emails”. While you can’t do anything tricky, it’s true, there is so much more to consider, and it’s all pretty annoying if you are used to designing for the web. I enjoy designing for IE6 slightly better than designing email templates.

With that frustration in mind, here are some tips I ran across that might be useful for you, but will be very useful for me as I know I will forget them all just in time to design a new set of templates:

Design Specifically – Everything needs a class

The most annoying aspect of Constant Contact for a web designer who liked their code to be clean and nested is the fact that IDs are NOT supported, and neither are styles on HTML elements. So, the CSS selector body p is a no-no. Not even a rule that uses an explicit h1. Instead, you must define a .header1 class and apply it to an h1, like this: <h1 class="header1">.

Ridiculous? Maybe… but here’s why. When Constant Contact assembles your email, it takes all these rules and spells them out explicitly right in the element. So while you may define a normal style, it uses it as a reference and spits out an inline style tag on the element itself. So this:

[code lang="html" light="true" wraplines="true"]
.header1 { font-weight: bold; font-size: 20px; color: #333333; } &lt;h1 class="header1"&gt;A Sample Header&lt;/h1&gt;[/code]

Becomes:

[code lang="html" light="true" wraplines="true"]
&lt;h1 size="20" color="#333333" style="font-weight: bold; font-size: 20px; color: #333333;"&gt;A Sample Header&lt;/h1&gt;[/code]

It does this so it can cover the widest array of email clients out there. And it would be maddening for us to try and code this way with all those inline styles. So while the idea of using a stylesheet is like the web, the way Constant Contact uses the stylesheet is not like the web at all.

Design like it’s 1993

We all know KISS, but when I say simple, I mean REAL simple… 1993, beginnings-of-the-internet simple. Take the <center> tag, for example. The good ole margin: 0 auto; won’t work consistently enough, so break out the dusty <center> tag instead.

Use tables for layout. I know, I know, that’s SO 1993, but I’m serious… trying to consistently float divs and clear floats will drive you mad.

Also, forget bit-saving CSS shorthand. You’re better off using the full six-character hex values for colors when you normally might use three. Four values for padding and margin seems to be well supported, but use the long-form tags for font-size, font-weight, font-family, and background properties. Actually, forget background images all together. Many email clients won’t load them.

When using images, style the container like its text

This one may not be very intuitive, but let me explain. I’ve got an image, and it’s important – it’s the logo. I know some email clients won’t load the image by default (looking at you, Gmail), so when the image doesn’t load, I want the contents of the alt tag to display instead, and I want it to look good.

To do this, I simply made sure the container that the image is placed inside has some fallback styles for text. So while the alt text disappears when the image loads, if the user never loads the image, it still looks nice and we don’t lose important information, like the name of the company. Here’s what I’m talking about:

Before images load...

With images loaded.

Use Anchor (Jump) links Carefully

This one particularly bugged me, and took a little time to figure out. The client wanted a Table of Contents with simple anchor links to make the email jump down to the proper element. I knew that support for hrefs that jump down to an element with an ID would be spotty, but a simple <a name="anchor"> would work, right?

Silly me, what was I thinking?

Besides the fact that even these basic elements have spotty support (see this article from Campaign Monitor), there is also a problem of styling and the way Constant Contact handles empty HTML elements.

In order to appease the greatest number of email clients, my code for anchors links was <a name="anchorname" id="anchorname"></a>. But there was a simple problem with that. Since it was empty, Constant Contact turned it into a self-closing xHTML element, which looks like this in the source of the email: <a name="anchorname" id="anchorname" />. The problem is, most email clients won’t recognize an anchor tag that self-closes, so my email had open anchors everywhere, which turned my text default link blue.

The solution is god-awful, and I would never allow my web pages to look like this, but this is what I had to do for it to work and look good. I had to add a style class to handle these links, because even though there is no HREF declaration, email clients will still treat it like a link and turn it default link blue. :

[code lang="html" light="true" wraplines="true"]
<h3 class="header3"><a name="anchorname" id="anchorname" class="anchor">Headline Text</a></h3>
[/code]

Send us Your Tricks!

Designing emails is frustrating enough… and this list is by no means exhaustive. What issues have you encountered? Send them over here and we’ll keep them compiled for you!

In Conclusion

I hope you never have to design email templates, because they really can be frustrating. All the efficiencies you’ve learned while designing for the web get thrown out the window. Still, email is an effective (and cost effective) form of communication, so it won’t go away. It can only get easier as older mail browsers are slowly phased out, but the fight to eradicate IE6 is nothing compared to the fight to eradicate Outlook (Outlook has no support for simple styles like padding and float).

In short, stay sane, stay calm, and use Google to help you figure out the baffling problems of designing email templates. Keep the design simple and the message short.

And good luck… you’ll need it.

C. Murray Consulting Oomph’s second post on Smashing Magazine, Advanced Power Tips for WordPress Template Developers, was published on the morning of November 25, 2009.

Advanced Power Tips for WordPress Template Developers

The original article covered 4 over-arching topics, and was so lengthy that the editors decided to split it into two parts! Part two – which focuses on customizing the administrative experience – will be published in two weeks.

Advanced Power Tips, part one, covers techniques for multi-block page / post content and digs deeper into methods for associating page content with post categories.

continue reading

WordPressEver since WordPress 2.5 was released, we’ve been pushing the boundaries of WordPress as a comprehensive CMS.

WordPress offers a wealth of plug-ins that extend the limitations of its reasonably light core; we’ve even contribued a couple of our own back to the community. But if you like to make slim, fast websites – like we do – you know that sometimes the plug-ins, and their overhead, are overkill.

Here are five power tips for template developers that address common CMS implementation challenges with solutions that are not well documented or not entirely intuitive. Please note that all of the code here was written for and tested with the latest version of WordPress (2.7.1). Some of the functions may not be compatible with older versions, or may require some initialization (i.e. global $post).

continue reading

Oomph is a full-service digital agency providing strategy, design & development and a host of other web services. A leader in WordPress and Drupal implementation, Oomph pushes the boundaries of today’s web platforms. Oomph has a diverse portfolio of non-profits, international corporations and publications. Team Oomph is always thinking creatively about the digital world. Oomph is located in Providence and Boston.