开发者

Way validate HTML code for gmail?

I got some auto generated HMLT code working. Made sure it is correctly parsed by http://validator.w3.org/, and it is a working HTML4.01 Strict.

Now, when I embed this code in a email and send it to gmail, the result is quite adverse (messes up the formatting).

The code is quite long, and apparently only happens when it has such size. This tells me two things:

  • not worth putting a code snippet here
  • it is probably some conflicting tag, but still considered valid the parser

Would you guys k开发者_JAVA百科now of any tool even more strict to validate my HTML? Maybe even something specific for gmail?

Or maybe, just some pro tip on what usually screws the code for gmail.

ps.: the code, although is long, is also quite simple, only a few tables and styles - I took some care in making sure used only "email friendly" tags and formats.


Did you say styles? Oh, boy! Email clients are all doing things differently and even if you get it working for GMail, it may not work for Yahoo.

You may want to look at something like Email CSS guide to start, but really you also want to use some of the Inbox Analysis services (e.g. Inbox Inspector from MailChimp) to get a better picture.

I haven't done this myself (yet), but I have seen mentioned over and over that this is one area you can lose your hair over.


You have to code like its 1999 and not worry about being so tied to conformity to HTML.


Unfortunately valid HTML just doesn't work for some (most) email clients. Even Gmail will strip or ignore things probably for security reasons. The best bet for an email is basically HTML 3. Some inline styles for fonts. I know that <p> tags break in Gmail, and in general colspan and rowspan won't work as intended and you have to use nested tables. Those are just a few things I can think of off the top of my head.


All the answers here helped, but the actual problem was elsewhere.

The problem was In the HTML as I thought, but not exactly in my HTML.

Turns out the the email client will wrap lines too big before handling it to render, regardless if it is HTML code or whatever, more exactly, breaking tags in the middle - that explain why it was happening only when the report reached a certain length.

What tipped me that was when I looked at the code generated by MailChimp (suggested by Alexandre Rafalovitch) and noticed it was formatted as quoted-printable, cropped at exactly 75chars for every line.

After that was easy enough to do the same in my own code generator. Well, actually, I didn't even format as quoted-printable, only made sure it would wrap too long lines by itself.

Apart from that, for all I can tell, a HTML 4.01 Strict code will work pretty much fine in a Gmail client.

Hope it helps post-1999 generations.

cheers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜