dlanger / inlinestyler

A simple CSS inliner for generating HTML email messages.
http://pypi.python.org/pypi/inlinestyler
BSD 3-Clause "New" or "Revised" License
114 stars 23 forks source link

Generated HTML has self-closing tags: disliked by GMail #9

Closed exomoxo closed 8 years ago

exomoxo commented 9 years ago

When certain HTML tags are turned into self-closing versions (e.g. <title />), GMail considers the entire HTML as invalid and will not display it.

  1. A quick workaround is to set method="html" in the etree.tostring call.
  2. On a more philosophical note, I'm not certain if the HTML standard allows or disallows self-closing tags.
exomoxo commented 9 years ago

To be honest, I'm not even sure if this should fall under inlinestyler. Feel free to close it :)

dlanger commented 9 years ago

I think it's a version-of-HTML thing. HTML5 doens't like them (in most cases, I think), but it's valid older stuff.

I'm going to leave this open for now since I'm not sure which the right approach is, and we'll see if the current behaviour bothers anyone else enough to comment with a strong opinion.

eswald commented 8 years ago

It's a differences between HTML and XHTML. The former has certain tags that should be closed, and others that should not; valid HTML always closes the former, and never the latter. Self-closing tags are technically invalid in HTML, but the slash can be safely ignored as long as a space precedes it; in such cases, the tag is considered still open unless it's an unclosed type. XHTML requires that all tags be closed, but either way can be used for any tag.

Meanwhile, the suggested fix works well, and fixes other minor bits of technically invalid output, while making the following line ("Tedious raw conversion of line breaks") obsolete.