Today, I want to write about a "low-tech" problem. By the way, I subscribe to quite a few newsletters, such as JavaScript Weekly. Get a weekly email with the week's big news. One day, I was thinking, could I also make an email like this? Then, I realized it wasn’t that easy. Putting aside the backend and editing work, just designing an email template requires a lot of thought. Because this formatted email is actually a web page, its official name is HTML Email. Whether it can be displayed properly depends entirely on the email client. Most email clients (such as Outlook and Gmail) will filter HTML settings, making emails unrecognizable. I found that the trick to writing HTML emails is to use the same methods used to create web pages 15 years ago. Here is the writing guide I put together. 1. Doctype Currently, the most compatible Doctype is XHTML 1.0 Strict. In fact, Gmail and Hotmail will delete your Doctype and replace it with this Doctype. XML/HTML CodeCopy content to clipboard
Using this Doctype means that HTML5 syntax cannot be used. 2. Layout The layout of a web page must use a table. First, place a large outer table to set the background. XML/HTML CodeCopy content to clipboard
The border property of the table is equal to 1, which is for the convenience of development. When officially released, set this property to 0. On the inner layer, place the second table. Used to display content. The width of the second table is set to 600 pixels to prevent it from exceeding the client's display width. XML/HTML CodeCopy content to clipboard
Set as many rows as the email content has. 3. Images Images are the only external resources that may be cited. Other external resources, such as style sheet files, font files, video files, etc., cannot be referenced at all. Some clients will add borders to image links, so you need to remove them. CSS CodeCopy content to clipboard
It should be noted that many clients do not display images by default (such as Gmail), so make sure that the main content can be read even without images. 4. Inline styles All CSS rules are best used inline. Because the style placed in the header of the web page is likely to be deleted by the client. For client support for CSS rules, please see here. Also, do not use CSS abbreviations, as some clients do not support them. For example, instead of writing: XML/HTML CodeCopy content to clipboard
If you want to express XML/HTML CodeCopy content to clipboard
To write it like this: XML/HTML CodeCopy content to clipboard
5. W3C Validation and Testing Tools To ensure that the final code can pass the W3C check, because some clients will strip unqualified attributes. Also use the test tools (1, 2, 3) to see the display results on different clients. When sending HTML Email, don't forget that the MIME type cannot be used XML/HTML CodeCopy content to clipboard
Instead, use XML/HTML CodeCopy content to clipboard
For sending tools, consider using MailChimp and Campaign Monitor. 6. Templates It’s a good idea to use templates that others have already made (here and here), and you can find more on the Internet. If you want to develop your own, you can refer to HTML Email Boilerplate and Emailology. |
<<: TypeScript union types, intersection types and type guards
>>: Detailed tutorial on installing Docker on CentOS 8.4
<br />I have summarized the annotation writi...
What is my.ini? my.ini is the configuration file ...
Effect screenshots: Implementation code: Copy code...
Table of contents Examples from real life Slow qu...
This article example shares the specific code of ...
1. Download and install Download the community ed...
First, take a look at Alibaba Cloud's officia...
It is already 2020. Hungry humans are no longer s...
<br />Introduction: This idea came to me whe...
Preface When using the MySQL database, sometimes ...
Preface Sometimes when hover pseudo-class adds a ...
When you send a network request, the following sa...
When the server needs to be started during develo...
Table of contents compose function Array.prototyp...
Pseudo-arrays and arrays In JavaScript, except fo...