Ros at Campaignmonitor’s blog mentioned the idea to minify your HTML to speed up the sending process. At first sight it seems to be a good idea, because the minified output will be much smaller without any unnecessary spaces, tabs, and line-breaks. A good HTML tidy solution will validate your code and reduce the size of your final HTML by stripping HTML comments and other “unnecessary” things from your email too.

But wait a minute!

So we will strip out all unnecessary spaces, tabs, and line-breaks which are covered by the HTML standards… but in email there are NO real standards!!!


Step one back, and think through what will happen with your HTML code. After the minifier removes all nonessential line breaks, the HTML will be in one “never-ending” line. Most email software have many inbuilt limitations. One of the trickiest limitations that exist in the Email Universe is the line length.

Modern HTML parsers can handle minified HTML and CSS as well, but Outlook won’t! Since old IE and MS Word engines, which are the basis of Outlooks, have problems with understanding long lines. Even the modern, Firefox based Thunderbird will break on the hard line break. These kind of breaks will have a really bad impact on your email designs and may ruin the whole layout of your email in some cases.

The line length limit is usually 998 characters plus CR and LF characters per line (for more: RFC5322). The same limitations exist in a lot server-side spam filter solutions too, so it is not so wise to remove all line breaks from your email HTML!

Is it safe to remove spaces and tabs?

Its a little bit harder to give a correct answer, but we’ll list he most common issues, so you can decide:

  • Some email clients may behave in a very strange way when you remove the tabs or spaces in front of the CSS selector in the HEAD of your HTML.
  • Some other desktop clients ignore CSS definitions without spaces on inline HTML style attribute. For example we discovered through heavy research, that Gmail ignores the background image of the email body, if we use the proper and valid CSS background property. But if you put one more space in the right place… It works!
  • There is a strange DOCTYPE and charset related issue, which causes problems in some cases.
  • Some of email clients only apply one CSS property:value combination per line in the HEAD style tag.

Minify is only a good idea if you can keep the line lengths, and all CSS related things untouched! In this case it’s a very good improvement that will definitely speed up your sending process, but DO NOT FORGET to TEST and be careful!

Gergely Mecs

Gergely Mecs

Chief Frontend Developer @

  • A Step-by-Step Guide to Sending Emails with PHP A Step-by-Step Guide to Sending Emails with PHP

    In this comprehensive guide you will learn the ins and outs of sending text and HTML emails with built-in packages and email delivery services using PHP.

    Read more
  • How to Use a Templating Language in HTML Email Development How to Use a Templating Language in HTML Email Development

    Shorten your development time with templating languages. EJS and the new JavaScript ES6 template strings can reduce the pain of responsive email coding.

    Read more
  • CSS Inliner Tools Worth Considering for Your Next Email CSS Inliner Tools Worth Considering for Your Next Email

    I hope you have never tried inlining CSS to your email code manually. Thankfully there are several CSS inliner tools. Check out their pros and cons.

    Read more