All Mail clients render HTML/CSS differently, in their own ways and for their own reasons. The differences in what HTML and CSS they support depends on many factors. When rendering HTML and CSS in emails many things impact what the end user is going to see. The mail exchange server, the preprocessor, the browsers, the rendering engines, and more; all affect the way your message is going to be displayed. These vary from client to client; browser to browser; server to server. However, don't start pulling your hair out just yet, because there are some best practices you can utilize so that your emails' coding will stay intact across different clients and platforms.
Avoid using padding or margins
Always use inline CSS
Most webmail clients (Outlook.com, Yahoo.com, Gmail, etc) will strip CSS out when stripping the head and body tags.
Avoid BR, HR, and height tags in your emails
Use Tables to create general layout of email
Set the width of each cell in the table.
Avoid cell spacing and padding.
Always set a "doctype" in your code
Set wrapper reset styles in "wrapper div"
Be aware of text and font changes per device (mobile especially) and browsers
Use the older more basic background HTML tags
Always offer reset background colors or fall back background colors to defer to if your specific background isn't supported
SendGrid Image Library - .jpg, .gif, and .png files can be uploaded to the SendGrid Editor for use with Email Designs
Always provide image dimensions
Some mail clients will automatically apply their own if none are given which can lead to major issues when rendering these images in relation to spacing and alignment.
Make sure to give ALL of your images 'alt' attributes - This simple step will keep the overall sizing of your images the same across platforms.
Outlook.com adds some pixels at the end of each image which can rearrange spacing, alignment, or padding
img {display:block;}
. This removes the padding in outlook.com and gives predictable results across many other email clients in terms of added spacing or padding to images.Avoid 'float' tags
Outlook cannot support these tags, so SendGrid recommends using align tags. For example, <img src="image.jpeg" align="right">
.
Yahoo! has similar issues, so SendGrid recommends using align="top" for the image in question.
Due to low usage, this feature has been removed. Click here for more information.
To control the output of plain-text conversion do one of the following:
<pre>
tag around the line.<p>
tag around the sentence.Why can't you just automatically add <br />
tags to newlines upon conversion?
Due to the way plain text emails are sent ( RFC 5822, Revised 2008) mailers are required to wrap lines at 998 characters, and recommends wrapping at 78 characters (excluding CR/LF). As a result, long sentences can often be broken up into multiple lines. Adding <br />
tags to each newline would create formatting problems.
For more information
We use the open-source library MKDoc-Text-Structured to perform the plain-text to HTML conversion. More information about this library and how it works can be found on the MKDoc-Text-Structured documentation page.
If you're still having issues, please contact our support team for help. We can provide the tools and the knowledge base to help you understand what your mail will look like across platforms and how to gain insight in making them appear consistent across these platforms.