Best Practices for Email Templates
This document describes some of the best practices around email design resulting in a well-developed email campaign template.
The demo campaign available in AEM follows all of these best practices. How the best practices are implemented in the demo campaign is described for each best practice.
Use these best practices when creating your own newsletter.
All campaign content should be created under a master page of type cq/personalization/components/ambitpage . For example if you are planning a campaign structure is something like:
You should make sure it resides under a master page:
When creating a mail template for Adobe Campaign, you must include the property acMapping with the value mapRecipient in the jcr:content node of the template, or you will not be able to select the Adobe Campaign template in Page Properties of AEM (field is disabled).
Specify document type to ensure consistent rendering.
Add DOCTYPE at the beginning (HTML or XHTML)
Is configurable by design changing the cq:doctype property in "/etc/designs/default/jcr:content/campaign_newsletterpage"
The default is "XHTML":
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Can be changed to "HTML_5":
Specify character definition to ensure correct rendering of special characters.
Add CHARSET declaration (e.g. iso-8859-15, UTF-8) to <head>
Is set to UTF-8.
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
Code all structure using the <table>element. For more complicated layouts, you should nest tables to build complex structures.
Email should look good even without css.
Tables are used throughout the whole template for structuring content. Currently using a maximum of four nested tables (1 base table + max. 3 nesting levels)
<div> tags are only used in author mode to ensure proper component editing.
|Use element attributes (such as cellpadding, valign, and width) to set table dimensions. This forces a box-model structure.|
All tables contain necessary attributes like border , cellpadding , cellspacing and width .
To harmonize element positioning inside tables, all table cells have the attribute valign="top" being set.
Account for mobile-friendliness, if possible. Use media queries to increase text sizes on small screens, provide thumb-sized hit areas for links.
Make an email responsive if the design allows for it.
|As far as CSS styles are being used to illustrate demo design, media queries are being used to offer a mobile friendly version.|
|Inline CSS is better than putting all the CSS at the beginning.|
To better demonstrate the underlying HTML structure and ease the possibility to customize the newsletter structure only some CSS definitions have been inlined.
Base styles and template variations have been extracted to a style block in the <head> of the page. On final submission of the newsletter these CSS definitions should be inlined into the HTML. An automatic inlinening mechansim is planned, but currently not available.
|Keep your CSS simple. Avoid compound style declarations, shorthand code, CSS layout properties, complex selectors and pseudo-elements.||As far as CSS styles are being used to illustrate demo design, the CSS recommendations are being followed.|
|Emails should be 600-800 pixels maximum width. This will make them behave better within the preview-pane size provided by many clients.||The width of content table is limited to 600px in demo design.|
Add alt attributes to images
The alt attribute has been defined as mandatory for the image component.
Use jpg instead of png format for images
Images will always be served as JPG by the image component.
Use <img> element instead of background images in a table.
No background image data is used in the templates.
Add attribute style="display block" on pictures. Allows to display well on Gmail.
All images contain per default the style="display block" attribute.
Use W3C validator to correct the HTML code. Make sure all open tags are properly closed.
Code was validated. For XHTML transitional Doctype only the missing xmlns attribute for the <html> element is missing.
Add a plain text version for multipart sending.
A new widget was build into the page properties to easily extract a plaintext version from the page content. This can be used as a starting point for the final plaintext version.