CSS and E mail, Kissing in a Tree – A Checklist Aside

Most individuals who’ve tried to recreate a complicated design in HTML e-mail have run right into a wall when utilizing CSS, both within the type of inexplicable mangling by e-mail purchasers or a pronouncement by an e-mail administrator stating that CSS is “towards the principles.” In the event you’re not content material to roll over and use font tags in your HTML emails, learn on.

Article Continues Beneath

Regardless of prevailing knowledge on the contrary, you possibly can safely deploy HTML emails styled with good old style CSS. Sure, I actually simply stated that. Not all attributes can be invited to the occasion, however a lot of them work flawlessly with this technique.

First comes love: unconditional acceptance#section2

From internet design publications, shop-talk conversations, and declarations from e-mail directors, I realized that sure e-mail purchasers slaughter CSS by stripping out the types or truncating the headers. I realized that if I ever dared to make use of CSS in an HTML e-mail, I ought to hyperlink to the type sheet reasonably than embedding it.

I by no means learn something on the contrary or encountered an e-mail administrator who allowed my use of CSS with out an all-out struggle, so I accepted the traditional knowledge. However after I bought fired up about the entire thing and determined to experiment, I used to be amazed at what I uncovered.

Then comes marriage: questioning typical knowledge#section3

I made a decision that the one method to discover a technique for utilizing CSS in HTML emails was to query all that I had realized and to interrupt all of the “guidelines.” Having been free of these guidelines, I explored each approach that confirmed even the slightest promise. Right here’s the way it went down:

  1. I designed an e-mail utilizing a linked type sheet and blasted it by a server-administration software to a number of addresses linked to a number of web- and desktop-based e-mail purchasers. (Whereas I didn’t conduct the take a look at utilizing each e-mail consumer, I did take a look at the market leaders on Mac, PC, and Unix.)
  2. After a few rounds, I moved ahead with embedded types. This turned out to be my first step to success. (In additional help of embedded types, you will need to be aware that AOL variations 6.0+ will reject any e-mail linking to exterior type sheets. Sure: reject, bounce, slam the door in your digital face.)
  3. I considered the supply code (a feat in itself in webmail purchasers) to determine simply how they have been bastardizing my treasured e-mail.
  4. Lastly, I used my evaluation of the mangled code to check strategies that may, in idea, forestall such mangling from occurring.

After I considered the supply code, I found there was much more occurring than I’d suspected. It was unbelievable. In reality, a lot of the HTML wasn’t even HTML — it was mixed-breed coding and (presumably) proprietary tags.

Then comes the child within the child carriage: outcomes and proposals#section4

Each e-mail consumer had a special approach of rendering the code, every with its personal distinctive bugs, quirks, and strategies for dealing with CSS. What follows is an inventory of essentially the most vital challenges together with their options.


The shells of web-based purchasers are constructed utilizing HTML, which consequently ends in the looks of two physique tags when displaying an HTML e-mail message. Some purchasers try and resolve the difficulty by stripping the physique tag altogether; others append the tag with an “x,” thereby altering <physique> to <xbody>. In each instances, the type defining the physique tag turns into null and void.


Envelop the whole contents of your e-mail in a div and apply your supposed physique attributes to the div as a substitute. Voila! A easy and compliant treatment, utilizing just one extraneous <div> tag.


Some purchasers rendered my e-mail with no type in any way. I first attributed this to the stripping of types, however I then found that the types have been clearly seen within the supply code. I subsequently spent a great deal of time making an attempt to uncover the perpetrator, testing numerous variations of the e-mail. Alas, the issue was proper underneath my nostril: the types weren’t being stripped — the dots (.) previous their names have been. Subsequently, “.Characteristic {}” turned “Characteristic {}”, leading to a meaningless type definition.


I used class selectors, which ensured that every type would start with a letter as a substitute of a dot. So “.Characteristic {}” would grow to be “td.Characteristic {}” or “div.Characteristic {}” (relying on the applying). A considerably mundane repair, however efficient and (once more) compliant.


As a result of webmail purchasers are utilizing their very own type sheets, and since they preceded mine, the cascading guidelines of “cascading” type sheets resulted in mine overruling these of the consumer. So my pseudo-classes and ingredient definitions (resembling “a:hyperlink {}” and “td {}”) inadvertently altered the design of the webmail consumer itself. D’oh!


I custom-made each definition. Thus, “a:hyperlink {}” would grow to be each “span.Characteristic a:hyperlink {}” and “td.Content material a:hyperlink {}” to accommodate HTML hyperlinks in each places within the doc tree. This unorthodox method provides deal code, however ensures that my types are utilized solely to the weather in my e-mail. It additionally affords respect to each the designers of the webmail consumer and people utilizing it. And, most vital, the ensuing code was compliant and functioned as supposed.


Hotmail: the most important demon of all of them. It has no mercy for HTML emails using CSS. It not solely eradicated my types, but additionally all the following tags from my e-mail: <head>, <title>, <meta>, and <physique>. Kiss aesthetic design goodbye.


I like to recommend rigorously contemplating how far you need to go to accommodate Hotmail’s ineptitude, as a result of the next technique provides the <robust> tag to “dedication” and “diligence.” For the reason that <physique> tag and every part previous it are gone, the one remaining technique for making use of CSS is Inline. Inline types are inefficient and tedious, and I’m certain you’d “reasonably be {golfing},” however it works. In the event you anticipate heavy Hotmail use by your supposed viewers, you need to use this technique to assist guarantee success. But when Hotmail will not be a difficulty for you, you possibly can skip this step and as a substitute handle the vital issues in your life, like consuming and sleeping.


Earlier than you rake me over the coals since you’ve discovered an attribute that fails utilizing any of those methods, please bear in mind that I haven’t but examined all CSS attributes for achievement. I did take a look at widespread attributes and people who I take advantage of incessantly. It’s possible you’ll discover that your favourite attribute fails, and for that you’ve my sympathy and my encouragement to check further strategies.

Purchasers examined#section15

I examined MailApp 1.3.2 (Mac), Squirrel Mail (Mac/Home windows), AOL 7.0, 8.0, 9.0 (Mac/Home windows), Mozilla Thunderbird 0.5 (Mac/Unix), Yahoo Mail (Mac/Home windows), Hotmail (Mac/Home windows), and Microsoft Outlook 2001/XP (Home windows).

I might love to listen to from you if this method fails in your surroundings. Please be aware that Eudora’s help for HTML generally is extremely poor, so I excluded it from testing altogether.

Leave a Comment