Back when we were running Dialect we developed quite a few newsletter templates for our clients. We always strove for pixel-perfect designs on the web, so HTML email’s rendering quirks were a major frustration (to put it mildly).

To improve the email design process I wrote Premailer. Premailer allows developers to write their HTML and CSS separately and then inlines all the CSS into HTML attributes before delivery.

As part of developing Premailer I also wrote a CSS parser in Ruby. This was easily my favourite part of the project. Being self-taught I had never learned to write tokenizers/parsers in school so it was pretty fun to dive into a spec and gradually make the test cases go green.

Premailer lives on thanks to the great Ruby community and is still accessible via its web interface.

CSS inlined into an HTML newsletter Premailer made this atrocious code so you didn’t have to…