Places to note When writing HTML-formatted messages

Source: Internet
Author: User

Preface: When sending e-mail with Javamailsender in Springboot project, I want to add "click Show" JS effect to the Exception log. After discovering the JavaScript code written in Java background and the OnClick method in the DOM object, F12 view is missing after receiving the message.

Online also can not find similar mail sent to add JavaScript similar case, after searching this article, the original mail server side directly filtered out the JS code ...

1. The style definition in head is invalid: Generally write Web pages, like to define CSS styles in the head, unfortunately, in HTML-formatted messages, some of the mailboxes will be invalidated.

2, the structure as simple as possible, preferably using table layout, you can first use table as the largest parent, need to center, can be set align= "center". This ensures that the layout and style are restored to the maximum extent that the CSS style is invalidated, or if the HTML is disabled.

3, do not use JavaScript and flash, will generally be filtered.

4, using the inline CSS style, what elements need style to write inline CSS with style, such as <td style= "color:red" > Warning </td>, do not introduce external CSS files, do not use style tags, Style tags are not supported for Gmail.

5. Do not use absolute positioning, do not use background images, do not use translucent, do not use IE filters and CSS expressions

6, the picture to add Alt and Border=0 property, set the Alt attribute is to prevent the picture display, at least there is text description, let the user understand the meaning. Ensure that valid information is passed in case the picture is disabled.

7. Display:block can be set for IMG to fix some blank space below the email client picture.

8, the picture adds the width high property

9. Do not attempt to use an IFRAME to introduce external pages

10, as far as possible to streamline the code, reduce the number of pictures and volume

11, generally use UTF-8 code

12, try to use padding, less with margin, not allowed to use margin as an important layout basis, do not allow the use of negative margin, avoid the use of non-zero and non-auto margin properties.

13. Avoid using List-style to handle list styles, you can use the "? "Characters instead.

Original source: http://www.studyofnet.com/news/889.html

Places to note When writing HTML-formatted messages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.