Blog Post RSS ?

Blogs » Web Tech » Conditional Comments for HTML Email
 

Conditional Comments for HTML Email


  • Save to
    Del.icio.us

by James Edwards

Take a look at this:

<!--[if gte mso 9]>

<![endif]-->

Chances are the general syntax will be instantly familiar — it’s a conditional comment, useful for feeding specific content only to Windows versions of Internet Explorer. But did you know they work for Office applications too?

Neither did I … until recently.

We’ve just overhauled the HTML templates for our email newsletters … a painful process to be sure — if you think that web browsers are harsh task-masters, you should try coding to suit email clients! A recent article, How to Code HTML Email Newsletters, spells out just how convoluted it can be, and how arcane are the techniques you have to resort to, to produce a decent layout in the most popular email clients. And the issue has been further complicated by the fact that one of the most popular Windows clients — Outlook — no longer uses Internet Explorer for HTML rendering, it uses Word!

And it was while perusing the franken-code that passes for “Save as Web Page” output from a Word document, that I first saw these little nuggets — exactly what we needed to hide bits of content from Outlook that were just too mangled to leave.

So there you go. If you’re publishing HTML email and struggling with Outlook’s rendering, here’s an extra little tool for the kit. The syntax even implies that it can be used for granular targetting of Office versions all the way back; but I haven’t tested this, so any information is gratefully received :)

This post has 9 responses so far

  1. I’m viewing this post in Opera 9.5 and the conditional comment doesn’t show up even though it did when I was viewing the feed entry from within Opera.

    And on the subject of your new HTML emails, they actually appear a bit broken in the header when viewed in Opera (the old version wasn’t).

     
  2. Hmmm, I’ve just come back to the page again and I can see the CC now. Not sure what was going on before. :/

     
  3. Yeah I know they are a little out of whack in opera (because like you, i live and breathe in opera :)) but they weren’t really targetted at web browsers - there’s only so many client environments one can deal with at a time :)

     
  4. >>Outlook — no longer uses Internet Explorer for HTML rendering, it uses Word!

    I knew there was another reason why I won’t use Outlook. Don’t use Word, either. Wish I didn’t use Windows.

     
  5. Nice one guys, this could really make life easier those (too frequent) occasions when Outlook 2007 won’t play ball. We did some additional testing on this method and wrote about the results on our blog.

     
  6. This is a huge help! I’ve tried conditional comments to target different email clients to no avail, but never would have tried “gte mso 9“. What does this mean?

     
  7. Brothercake: Get rid of Opera!!!

     
  8. This is a huge help! I’ve tried conditional comments to target different email clients to no avail, but never would have tried “gte mso 9“. What does this mean?

    Greater Than or Equal to MicroSoft Outlook 9

     
  9. Greater Than or Equal to MicroSoft Outlook 9

    Ah, it almost makes too much sense.. I’m still quite surprised that it works. Many many kudos to James Edwards and Sitepoint! My boss came back to me and asked me how I got this to work. Keep the .html email stuff coming!!

     

Sponsored Links

Leave a response

You are not logged in, log in with your SitePoint Forum username and password.

-OR- Post Anonymously

* Make sure any code samples are escaped (i.e. ‘<b>’ becomes ‘&lt;b&gt;’).

If not logged in, your comments will be placed in a moderation queue. This means your comment may not appear until one of our moderators approves it.

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.

Logo Design, Web page Design and more!

99designs

  • Custom logo designs created ‘just for you’.
  • Pick the design you like best.
  • Only pay if you’re satisfied with the result.

Want More Traffic?

Get up to five quotes from qualified SEO specialists, with no obligation!

Get A Free SEO Quote Now!