Archive for October, 2008

HTML email template best practices

10

Oct
31

Every so often I am required to build email templates and am constantly amazed by the new and bizarre bugs I come across. Having worked my way through a mountain of email client “features” over the years I thought it would be good to put together a simple best practice guide to building an email template.

Best Practice

  • Use tables to provide positioning and layout as this will provide the greatest levels of consistency cross browser. In many cases the simpler the code the better.
  • Inline styles should be used to create the desired creative effect again to reduce the risk of cross browser inconsistencies.I.e.
    <span style="color:#000000;">
  • Apply fixed pixel sizes for font sizes and height/widths.
  • Use span tags with inline styles instead of p, h1 tags etc. Most browsers apply natural padding and margin to p, h1 tags, so by using span tags you can eliminate this as a factor.
  • Avoid shorthand – some email clients have a habit of removing shorthand and replacing with the longhand equivalent (and doing it very badly). It’s therefore much easier to take away the risk of this happening and only using longhand from the start.I.e.
    <span style="margin-top:10px;display:block;">testing</span>

    instead of:

    <span style="margin:10px 0px 0px 0px;display:block;">testing</span>
  • Use the table background attribute to apply background images instead of using CSS. This is the most universal approach, however, it is worth remembering that Outlook 2007 does not allow background images at all.I.e.
    <table cellpadding="0" cellspacing="0" border="0" background="http://www.mydomain.com/images/email-010101/myimage.gif">
        <tr>
            <td>
                Content here
            </td>
        </tr>
    </table>
  • If background images are used, apply a background colour to provide the same colour styling as the bg image.  This will provide structre to email clients that do not render background images.
  • Where an image is inserted apply an inline style of display block. This removes extra margin applied in Windows Live Hotmail through Firefox.
  • Reference images on a live server. This will help reduce the weight of the email as well as decreasing the risk of your template being picked up as spam as spammers have like to embed images into emails.
  • Images and text must be used in proportion again to avoid the risk of being picked up as spam. Spammers like to include the message of their email in images to avoid email filters recognising blacklisted words.
  • Although JavaScript does work in some email clients its coverage is by know means complete. Until there is better wide spread support JavaScript should not be used.
  • Forms should not be used within an email template. As with JavaScript,there is support in some email clients but not all so they are best avoided.
  • Do not heavily nest tables within tables as older email clients such as Lotus Notes do not like it.

Useful Links

The Campaign Monitor blog has some very helpful CSS support guides for different email clients. Very interesting and well worth a read as it can save you a great deal of time in the long run.

- Visit Campaign Monitor

The Email Standards site “helps designers understand why web standards are so important for email, while working with email client developers to ensure that emails render consistently”. Another good read with some very helpful information.

- Visit the Email Standards

Mootools Idle State Notifier

5

Oct
22

Last year I wrote a simple JavaScript function, for prototype, to mimic an idle state event. The code was very simple and was quickly picked up on by think web2 (perfection kills) where they extended the idea and developed a self containing class which fires active and idle custom events.

After using this code on several projects I decided to port it over to Mootools 1.2 (also works in Mootools 1.1) so check it out the demo below and if you like it feel free to download the code.

demo

Mootools Idle State Notifier demo.

download

Mootools Idle State Notifier download.

Flash Movies as Backgrounds

20

Oct
13

Ever wondered how to set a flash movie as your website background? Well here’s a simple approach that can be used.

The following tutorial will guide you through the process of “layering” a page in a way to give the appearance of a flash background.

The are however a couple of points that are worth noting.  These include:

  • Absolute positioning is used to add content above the flash movie.  This therefore mean that the content is taken out of the flow of the document and when resizing the page content may be cut off unless a good workaround is used.
  • UFO (Unobtrusive Flash Objects) is used to embed the flash background although you could, and probably should, use SWFObject instead.

flash background HTML

The HTML below provides a simple structure and can be broken in to two sections, a div with id “flash-background” (used to house the flash background) and a second div with an id of “website” (contains your site content).

<div id=”flash-background”></div>
<div id=”website”>
<div class=”text-content”>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras porta sem et ligula. Nunc nec neque. Ut nec justo non lorem porttitor dictum. Etiam nec dui et odio egestas ornare. Quisque magna augue, tristique vel, egestas ac, lacinia et, purus. Curabitur varius. Sed tempor. Integer bibendum leo at urna. Ut tortor. Cras lobortis justo non lacus.</p>

<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras porta sem et ligula. Nunc nec neque. Ut nec justo non lorem porttitor dictum. Etiam nec dui et odio egestas ornare. Quisque magna augue, tristique vel, egestas ac, lacinia et, purus. Curabitur varius. Sed tempor. Integer bibendum leo at urna. Ut tortor. Cras lobortis justo non lacus.</p>

<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras porta sem et ligula. Nunc nec neque. Ut nec justo non lorem porttitor dictum. Etiam nec dui et odio egestas ornare. Quisque magna augue, tristique vel, egestas ac, lacinia et, purus. Curabitur varius. Sed tempor. Integer bibendum leo at urna. Ut tortor. Cras lobortis justo non lacus.</p>

<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras porta sem et ligula. Nunc nec neque. Ut nec justo non lorem porttitor dictum. Etiam nec dui et odio egestas ornare. Quisque magna augue, tristique vel, egestas ac, lacinia et, purus. Curabitur varius. Sed tempor. Integer bibendum leo at urna. Ut tortor. Cras lobortis justo non lacus.</p>

<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras porta sem et ligula. Nunc nec neque. Ut nec justo non lorem porttitor dictum. Etiam nec dui et odio egestas ornare. Quisque magna augue, tristique vel, egestas ac, lacinia et, purus. Curabitur varius. Sed tempor. Integer bibendum leo at urna. Ut tortor. Cras lobortis justo non lacus.</p>
</div>
</div>

flash background CSS

The CSS below is not very complex.  Set your default styling on the body I.e. font size, colour etc. The flash background div is positioned absolutely in the centre of the page with a z-index of 0 and website div is also positioned in the centre of the page with a z-index of 10000 (obviously doesn’t have to be that high I just wanted to show that it was larger :-) ).  CSS wise that is it, not very difficult at all.

body{
margin:0px;
padding:0px;
background-color:#666666;
font-family:arial;
font-size:80%;
color:#333333;
overflow:hidden;
}
#flash-background{
width:1014px;
height:960px;
text-align:left;
margin:0px auto;
position:absolute;
top:0px;
left:50%;
margin-left:-507px;
z-index:0;
}

#website{
width:800px;
height:400px;
text-align:left;
margin:30px auto;
position:relative;
z-index:10000;
background-image:url(images/overlay.png);
background-repeat:no-repeat;
}

.text-content{
padding:15px;
}

JavaScript

Finally we need to embed the flash movie into the page, in the example below I have used UFO, however, I would strongly advise you to use SWFObject 2.0 as this is currently the best solution in the market.

var FO = { movie:"flash/background.swf", width:"1014", height:"960", majorversion:"8", build:"0", xi:"true", wmode:"transparent" };
UFO.create(FO, "flash-background");

demo

Flash background demo.

download

Flash background download.

What’s New in Geo at GDD 2008 in London

3

Oct
13

YouTube API: Build YOUR YouTube at GDD 2008 in London

1

Oct
13