Line Length in HTML

Troubleshooting Line Length in HTML Email


Line length is one of those tricky elements that can cause strange rendering issues in email clients. These problems may appear to take different forms as the length of the line changes. To help you troubleshoot the problem, I’m going to explain its roots, how to spot it and how to fix it.

The problem

If all of the code for your HTML email is on a single line–or enough characters are on a single line–some email clients may have trouble parsing it. Usually this happens when a line goes over 1000 characters, as that’s the RFC required limit:

“There are two limits that this standard places on the number of characters in a line. Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF.

The 998 character limit is due to limitations in many implementations which send, receive, or store Internet Message Format messages that simply cannot handle more than 998 characters on a line. Receiving implementations would do well to handle an arbitrarily large number of characters in a line for robustness sake. However, there are so many implementations which (in compliance with the transport requirements of [RFC2821]) do not accept messages containing more than 1000 character including the CR and LF per line, it is important for implementations not to create such messages.

The more conservative 78 character recommendation is to accommodate the many implementations of user interfaces that display these messages which may truncate, or disastrously wrap, the display of more than 78 characters per line, in spite of the fact that such implementations are non-conformant to the intent of this specification (and that of [RFC2821] if they actually cause information to be lost). Again, even though this limitation is put on messages, it is incumbent upon implementations which display messages to handle an arbitrarily large number of characters in a line (certainly at least up to the 998 character limit) for the sake of robustness.”

As you can see, though they do suggest that clients receiving email be able to handle “an arbitrarily large number of characters,” some transport agents may not be able to handle more than 1000 characters per line. When any transfer agent or email client that can’t handle more than 1000 characters per line receives it, the line will be broken as it moves through the code at a possibly arbitrary point. If that break happens in the middle of an HTML tag, it could make the tag unreadable.

How to spot the problem

The most common way this problem appears is as hanging bits of code in your email, sometimes accompanied by display errors. If the broken tag was important for the correct display, such as an opening table tag, it may alter the layout of the email.

To create an example of the problems this can cause, we took our Coffee Shop fluid hybrid template and sent it with all the code on one line. The screenshot below is from Outlook 2013.

You might not see this problem in the same way in every email client, as it depends on the mail transfer agents that touch the code as it is passed along from the sending service, through the internet and received by the email client on the other end. For a quick summary of how an email is actually sent, check out this article. There are a lot of variables in the process!

How to fix the problem

Fortunately, the fix is easy: Make sure that you don’t code emails with more than 1000 characters per line, which is a pretty generous limit. If you parse your code before sending it out, you can set this limit in the sending program. If not, you can manually make sure that there is a line break every 900 characters, or after each tag in your email.

If you find that the problem persists even after you manually add line breaks, it may be that your ESP (or sending program) is removing line breaks before sending the email. If that’s the case, work directly with them to resolve the issue.

Test before you send!

It’s issues like these that make email testing so important. The only way to way to remedy a problem like line length breaking your code before you send is to know that it exists. Sign up for a 7 day free trial to discover and fix these issues today!

3 thoughts on “Troubleshooting Line Length in HTML Email”

  1. You would think this would not be a factor depending on what body encoding you are using (e.g. quoted printable, base64)

  2. Just found that SFMC forces their own line breaks after 700 characters. So if you’re sending with them be aware of this reduced limit, and be aware that other ESP may also enforce their own arbitrary line lengths.

  3. Terricic article! Тhis is tһе type of info tһat should be shaared acrоss the web.
    Disgrace on Gogle fοr not positioning tһis post hіgher!
    Comee on ovеr аnd talk ᧐vеr ԝith my website .
    Tһanks =)

Leave a Reply

Your email address will not be published. Required fields are marked *

Free Email Goodies