coding html email: best practices & tips

26
Coding HTML Email: Best Practices & Tips by Steve Hong (@st3v3hong) Senior Web Developer CrossComm, Inc. http://slideshare.net/stevehong/

Upload: steve-hong

Post on 01-Sep-2014

8.395 views

Category:

Technology


3 download

DESCRIPTION

Web designers and developers can easily adapt their skills to create styled and graphic-rich HTML emails for clients, but there are many key differences between webpages and email. Avoid the common pitfalls with a primer on best practices for coding HTML email. This presentation primarily covers coding and HTML/CSS support but also includes discussion of design conventions, testing and deliverability issues.

TRANSCRIPT

Page 1: Coding HTML Email: Best Practices & Tips

Coding HTML Email:Best Practices & Tipsby Steve Hong (@st3v3hong)Senior Web DeveloperCrossComm, Inc.

http://slideshare.net/stevehong/

Page 2: Coding HTML Email: Best Practices & Tips

•Coding HTML email SUCKS!

•Throw out web design best practices.

•Dust off bloated "old-school" HTML table layouts.

•Slap on inline CSS; no separation of presentation & content.

•Forget things like video, audio, Flash, scripts, and forms.

Prepare to be disappointed.

Page 3: Coding HTML Email: Best Practices & Tips

Wait! Don't leave!•HTML email is pretty and it works.

•Communicate better through design.

•Maintain consistent branding across all messages.

•Jump on the bandwagon. Everyone's using HTML email.

•Face it. There are no alternatives.

Page 4: Coding HTML Email: Best Practices & Tips

Coding HTML email: Tips.

•Code HTML/CSS by hand rather than in a WYSIWYG editor to ensure the code is clean and only includes supported elements.

Page 5: Coding HTML Email: Best Practices & Tips

Coding HTML email: Tips.

•Use low-tech and simple table layouts without nesting or merging cells because CSS layouts with positioning don’t work.

Page 6: Coding HTML Email: Best Practices & Tips

Coding HTML email: Tips.•Code only long-hand inline CSS styles instead of external or head stylesheets. CSS short-hand like “font” may not work, so write out individual properties like “font-size.” 

Page 7: Coding HTML Email: Best Practices & Tips

Coding HTML email: Tips.

•Try a tool like Premailer to make your styles inline: •premailer.dialect.ca

Page 8: Coding HTML Email: Best Practices & Tips

Coding HTML email: Tips.•Use CSS primarily for text styling.

•Put general text styles on parent td cells but don’t rely on style inheritance from parent table cells to children cells.

•Use inline CSS on heading and paragraph tags to overwrite inherited styles.

Page 9: Coding HTML Email: Best Practices & Tips

Coding HTML email: Tips.

•Avoid font tags because they don’t yield consistent font sizes.

Page 10: Coding HTML Email: Best Practices & Tips

Coding HTML email: Tips.

•Wrap everything in a master 100% width table for background colors and other body styles because head and body tags are stripped out by webmail.

Page 11: Coding HTML Email: Best Practices & Tips

Coding HTML email: Tips.•Avoid conflicting with webmail CSS ID and class names by not using any or using unique names, like “clientname-footer”, rather than generic names, like “footer.”

Page 12: Coding HTML Email: Best Practices & Tips

Coding HTML email: Tips.•Reference images with absolute instead of relative paths because they’re hosted on a web server.

Page 13: Coding HTML Email: Best Practices & Tips

Coding HTML email: Tips.

•Use alt text in a header image to ask people to “please turn on images” so that they know they’re missing out when their webmail turns off images.

Page 14: Coding HTML Email: Best Practices & Tips

Coding HTML email: Tips.•Add CSS text styles to table cells even if they contain only images because alt text will be styled when images are turned off.

Page 15: Coding HTML Email: Best Practices & Tips

Coding HTML email: Tips.

•Take a look at MailChimp’s or CampaignMonitor's sample email templates:•bit.ly/mailchimptemp

•bit.ly/campmontemp

Page 16: Coding HTML Email: Best Practices & Tips

Coding HTML email: Tips.

•Check out CSS Tricks’ HTML email screencast for a how-to video: •bit.ly/csstricksemail

Page 17: Coding HTML Email: Best Practices & Tips

Test HTML email code.

•Test with images and CSS turned off using the Firefox Web Developer Toolbar plugin: •bit.ly/ffwebdevtoolbar

Page 18: Coding HTML Email: Best Practices & Tips

Test HTML email code.•Set up many webmail test addresses and install several desktop email programs for testing.

•For a fee, try MailChimp’s Inbox Inspector for final tests of your template: •bit.ly/mailchimpinsp

Page 19: Coding HTML Email: Best Practices & Tips

Test HTML email code.

•Avoid spam filters in testing by avoiding the word “test” and dummy text like “lorem ipsum.”

•Make every aspect of the email production-ready before testing it.

Page 20: Coding HTML Email: Best Practices & Tips

Look out for bugs.

•Gmail doesn’t honor background-repeat styles, so plan for repeating.

•Gmail doesn’t like quotes in font names. Don’t use “font-family:’Lucida Grande’,” but rather “font-family:Lucida Grande”.

Page 21: Coding HTML Email: Best Practices & Tips

Look out for bugs.•Gmail doesn’t like percentage values for CSS line-height. Outlook 2007 creates too much line-height when em sizes are used. Use pixel sizes.

•Gmail and Hotmail don’t display background images declared with CSS, so use the background attribute of the table and td tags.

Page 22: Coding HTML Email: Best Practices & Tips

Look out for bugs.

•Hotmail doesn’t like CSS margins. Try using padding instead.

•Hotmail sometimes adds extra space in cells with images. Try a line height of 70% of the font size like this: 12px font, 8px line-height

Page 23: Coding HTML Email: Best Practices & Tips

Look out for bugs.

•Yahoo uses non-standard align and valign default values on table cells, so set them explicitly.

•Yahoo has styles that make cellspacing ineffective on tables. Use cellpadding instead.

Page 24: Coding HTML Email: Best Practices & Tips

See other resources.

•MailChimp’s Guide:•bit.ly/mailchimpguide

•CampaignMonitor’s Guide to CSS support in email clients:•bit.ly/campmoncsschart

Page 25: Coding HTML Email: Best Practices & Tips

Contact me.

•Steve Hong, Senior Web Developer, CrossComm

[email protected]

•linkedin.com/in/stevehong

•www.crosscomm.net

•@st3v3hong

Page 26: Coding HTML Email: Best Practices & Tips

Find this online.•SlideShare: 

•http://slideshare.net/stevehong/

•CrossComm Blog: •crosscomm.net/blogs/web-strategy/online-marketing/how-

to-code-html-email/

•bit.ly/crosscommemailcode