Any limititations to HTML, CSS-styling, etc.?

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
HHahn
Forum Commoner
Posts: 43
Joined: Mon Mar 02, 2009 9:16 am
Location: Veldhoven, Netherlands

Any limititations to HTML, CSS-styling, etc.?

Post by HHahn »

This is not really a Swiftmailer question, but people using SwiftMailer may have run into situations related to my question.

In most applications where I intend to use SwiftMailer, table-like layouts will be used. Considering that Swiftmailer seems to accept anything that looks like decent HTML, I started experimenting with CSS styling as well. So far, this seems to work fine.

However, it looks fine in my e-mail client (Mozilla Thunderbird). Does anyone have any experience with limitations on the usage of HTML and/or CSS with different e-mail clients? Of course, Outlook is important, as many people don't bother using anything else, but I would not limit to that one.

[added – HH]
This question not only refers to CSS formatting of single tags, but also to using CSS classes!
[/added – HH]
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Any limititations to HTML, CSS-styling, etc.?

Post by Chris Corbyn »

HHahn
Forum Commoner
Posts: 43
Joined: Mon Mar 02, 2009 9:16 am
Location: Veldhoven, Netherlands

Re: Any limititations to HTML, CSS-styling, etc.?

Post by HHahn »

Thanks so far. The above link itself wasn't very helpful, but the page showed another link that was better.

However, I now see that I have put my question far too vaguely. I do not have the slightest intention to send highly designed e-mails. What I just want to do, is sending e-mails with "readable" text. E.g., an e-mail sent by a form page should have a correct column stucture, so that the data supplied can be quickly found and read. Some words may have to be highlighted (e.g. rendered bold), and so on.

When I send or receive a simple non-plain-text e-mail, I notice that in the source code more often than not things like <html>...</html> tags, <head>...</head> tags etc. are just missing. In fact HTML originally is very poorly defined language, allowing about everything that should actually be forbidden. (Hint: install an SGML parser like the one from http://users.skynet.be/mgueury/mozilla/, into your Firefox browser, and see that extremely few websites are really standards-compliant!)

So what I just want to know is the minimum requirements to be sure that a "decent" layout is indeed rendered "decently" in most e-mail clients. E.g., should I insert <html><head>...</head><body>...</body></html> tags? What about doctype declarations? Am I really allowed to put CSS class declarations inside the <body>...</body> section (which I actually should not do in websites if they are to be W3C-compliant), etc., etc.

Of course I can try myself what happens if I insert those things. But I have no idea how to be sure that the result is better in all (or most) e-mail clients than just omitting these things.
I hope this makes my question a buit clearer.
Hocker
Forum Newbie
Posts: 3
Joined: Wed Mar 25, 2009 10:54 am

Re: Any limititations to HTML, CSS-styling, etc.?

Post by Hocker »

You do not need to declare the <HTML> since this is a document that is meant to be
rendered by an email client, and not a web browser.
You can of course use them, they wont harm,
but wont bring any extra benefit.

Another thing to take into account is the fact that some email clients,
specially web based( eg: Hotmail, Yahoo, Gmail, etc) will strip the head
out of your message thus loosing all the declarations made in there,
like style, that's why I recommend using inline CSS, or declare
the style outside the head. I am not sure it using the <style> tag outside
the head of the document is standards-compliant!, but I know it works.
Post Reply