Creating HTML for email
Introduction
When a message is written directly in HTML, it is useful to know the specifications that allow it to be displayed correctly in most webmail services and email clients, such as Outlook and Thunderbird. These guidelines are based on the experience gained by ContactLab staff over the years and on the thousands of campaigns sent by clients.
Goal
The technical specifications to consider when creating HTML to send with ContactLab.
General Rule
The HTML of an email must be “simpler and cleaner” than the HTML of a web page. Webmail services and email clients have difficulty handling certain elements, such as stylesheets, JavaScript, and Flash, that browsers can manage easily.
The specifications below indicate which elements should not be included in the message to avoid display issues for the recipient.
Specifications
Content Layout
All message content must be placed inside a fixed-width table. Specify the width in the width attribute of the <table> tag.
The width must also be specified for each cell, for example, <td width="121">.
Recommended Width
The outermost table mentioned above should have a fixed width. The recommended width is 550 pixels. This prevents a horizontal scroll bar from appearing in most email clients and webmail services.
If a wider layout is required, the recommended maximum width is 600 pixels. Most email clients and webmail services display the message correctly at this width. If a horizontal scroll bar appears, it is minimal and should not inconvenience the recipient.
Recommended Length
There is no recommended length for technical reasons. However, newsletters and commercial DEM messages should not be too long to remain effective. Whenever possible, links to web pages should be included in the message.
<title> Tag in the <head>
Enter text in the <title> tag. Avoid leaving the default text assigned by the HTML editor, such as “Untitled1” or “New Page 1”. It is preferable to use text similar to the email subject.
Using Stylesheets
Stylesheets (CSS) should be used sparingly, as follows:
-
Do not use CSS to define the position of an element, such as image or table alignment, padding, or float.
-
Within the HTML of the newsletter, CSS can be:
- internal, in the
<head>tag. Internal CSS should be commented, meaning that all stylesheet elements except the<style>tag should be enclosed in comment symbols; - external, by including a link to the external stylesheet in the
<body>tag. The file can be hosted on the Contactsend server or on another server; - inline, by inserting CSS within cells and inside the
<link>and<div>tags where the class is called.
IMPORTANT: The three stylesheets must have the same characteristics.
- internal, in the
Images
Images should be uploaded to a server, either Contactsend's server or another server, and then inserted in the src attribute of the tag.
The format must be JPG or GIF. Animated GIFs are also supported. The use of mapped images is strongly discouraged.
Each image should be as small as possible to remain within the recommended total size of 60 KB.
Background Images
If the HTML contains background images, avoid using white text, or text in a color matching the <body> background. Recipients who have enabled image blocking in their email client will not be able to see the message correctly.
Background images cannot be included in the stylesheet. They must be inserted in the cell, for example, <td background="bg_ombra_2.gif">.
The use of background images is not recommended because they can cause display issues and are not supported by Outlook 2007.
Balancing Text and Images
Avoid using only images in the HTML, as this significantly increases the likelihood of the message being classified as spam. Text should be used instead of images whenever possible.
Very large images should be divided into two or more parts and then assembled using a table.
Image Naming
Assign each image a meaningful name that describes its content. Avoid names such as 001.gif, 002.gif, photo1.jpg, or photo2.jpg.
This practice reduces the risk of the message being classified as spam. Avoid spaces and accented letters in image names. Underscores can be used, for example, photo_vacation.jpg.
Characters
Pay attention to characters generated by Word, such as quotation marks, ellipses, dashes, and apostrophes. Replace them with the corresponding keyboard characters.
Recommended Weight
The combined size of the HTML and images should not exceed 60 KB.
Elements to Avoid
- Mapped images: Do not insert images that contain a map. Instead, divide the image and reassemble it in a table by linking the individual parts.
- JavaScript: Do not insert JavaScript into the HTML of the message.
- Flash: Do not insert Flash files (
.swf) into the HTML. If moving elements are required, use animated GIFs. - Linked text: Do not use the link URL as the link text. For example, avoid links such as
<a href="https://www.contactlab.com">www.contactlab.com</a>, because common email programs, including Thunderbird, perform anti-phishing checks that may flag these links as suspicious. Use text such as<a href="https://www.contactlab.com">Contactlab</a>instead.
It is also recommended to:
- include the phrase “If you are having trouble viewing this message, click here” at the top of the page, with a link to a static page hosted on the server or with the code
${online_version_url}$, so that the message can be viewed correctly; - include a reference to the Code regarding the processing of personal data and privacy at the bottom of the page;
- include a link at the bottom of the page that allows recipients to unsubscribe from the newsletter.
Unbreakable Limits
The specifications above allow correct display in most webmail services and email programs currently in use. However, some limits depend on the policies of individual providers or software manufacturers and cannot be resolved.
For example, Gmail and Hotmail are known to have policies that block stylesheets. As a result, the message may appear incorrectly in these webmail services even when the specifications are followed.
Display issues are also frequently reported with email programs in the Lotus suite.
Testing Emails Before Sending
The best way to check that an email is displayed correctly and that its elements work properly is to send a test before the actual delivery.
Contactsend allows a test filter to be created for each database, as described in Configure > User DB, and a test delivery to be sent, as described in Create > Email Shipment.
It is always advisable to include different addresses in the test and check the message using different email programs and webmail services.
Embedded Images
Normally, an HTML email requires the images contained in the message to be uploaded to an external server and loaded when the email is opened.
As an alternative to this standard procedure, images can be embedded in the message. In this case, the images are included directly in the email instead of being loaded from an external server.
Advantages and Disadvantages
The main reason for embedding images in an email is to avoid the image-blocking features implemented by most email clients and webmail services. This allows the message to be displayed with all images in place.
However, embedded images also have some disadvantages:
- They significantly increase the risk of the message being classified as spam.
- They increase the size of the email because the image size is added to the HTML size.
The tracking image used to track email openings cannot be embedded because it is inserted automatically by the system.
Procedure
The starting point is standard HTML in which the images are linked to and located on an external server, for example:
<img src="http://server.it/img/foto.jpg">
Then:
-
Manually modify the tags by inserting
@(before the image URL and)@immediately after the URL. For example:<img src="http://server.it/img/foto.jpg">becomes<img src="@(http://server.it/img/foto.jpg)@">. -
After modifying all the tags in the text as described above, save the modified HTML on the computer.
-
Go to Contactsend > Create > New Shipment > (group name) > Message Content.
-
In the message content screen, upload the modified HTML file using Upload from: a file on my computer.
The modified HTML is uploaded to ContactLab. Complete the shipment creation process by selecting Next. The images are included in the <body> of the message.
Perform a test to verify that the embedded images are displayed correctly.
If an <img> tag is not modified using the @(http://…)@ syntax, no error is generated. The image is still loaded from its server when the email is opened and may therefore be blocked by the image-blocking settings of the email client or webmail service.