CSS for mail doesn't apply? - html

I have no idea what's going on now. I threw together a simple page with very simple CSS. I used tables cause i know you can't use div elements like normal for emails. So after viewing it in my browser, it looks like this:
http://i.stack.imgur.com/8FBtf.png
And after sending it through mail (the cells data has been replaced):
http://i.stack.imgur.com/tuXvA.png
So the CSS doesn't apply at all!
Here's the HTML and CSS:
http://pastebin.com/PySeeW4m
Any ideas?

Most e-mail clients only read the CSS if it is provided inline through style= tags, Mailchimp provides a great tool to do this automatically:
CSS Inliner Tool

CSS in e-mail is only partially supported and support differs greatly amongst clients. Have a look at http://www.campaignmonitor.com/css/
You probably need to have all CSS inline for more compatibility.

please consider that f.i. gmail strips out style definitions from the HTML template.
You can use a workaround and include style information direct in the element like this
<div style="width:150px">...</div>
To use your css like it is right now just use a css parser and attach it to the elements via a regular expression
Regards

Related

Rendering HTML template in Email clients

I have HTML template completely written with div, a, img, button elements with inline CSS styling. It renders perfectly in HTML editors but not in Email clients. Should it be completely written in table form for Email clients? Here is my code:
Look it on JSFiddle
I believe your particular question is dependent on which email-client you are targeting. It would be helpful if you could specify which email-client you are looking to use, as well as which parts of your html are not working, because certain email-clients may not support certain parts of your code.
For example, as defined here,
Outlook has the following problems for rendering HTML:
Outlook does not “understand” HTML bulleted list tags
Outlook uses Times New Roman as the default font
Outlook may add a page break to an email if it exceeds 1800px
Outlook cleans up paragraph and margin spacing
Outlook does not support background images
Which you may be able to fix by using specific techniques, such as, as you mentioned, wrapping with tables. I found a link here that may be helpful if you are trying to resolve the rendering on Outlook.
If there is another specific email-client you need to target, there should be posts on stack overflow or on the web for resolving them as well.
Good luck!
You do have to use tables in email HTML and then use CSS and formatting to mask it. Here's a handy guide you can use for email HTML.

Inlining CSS for HTML email templates

Been trying to find a good inline tool and http://premailer.dialect.ca/ is the best I’ve found, but I believe it may not support styling (not certain). It could also be an issue with the pseudo classes “first-child”, “nth-child”, etc.
It may also have something to do with the table style “table-layout” however I do not know how to get around this. I’ve tried all the values found on MDN, but my styles are still not showing up when converted.
Been working at this for a while with little progress. I could always go back and change my CSS to not use pseudo classes, but hoping there’s another option. Let me know if there are any better tools out there for converting to inline CSS.
Using SCSS and importing all scss files into a single all.scss file.
References:
What tools to automatically inline CSS style to create email HTML code?
styling tr or td in emails?
https://developer.mozilla.org/en-US/docs/Web/CSS/table-layout
Closing off this question as it seems it is not the appropriate area to discuss email inlining tools.

How to apply embedded css in html email?

I want to apply embedded css in html email page. But when i am doing this all the css is not applying to html email when trying to send email using this html page. Any solution to enable css visibility in email when send this html page into an email ?
The best approach is to inline your CSS rather than use the <style> tag as it's not heavily supported.
HTML/CSS in email can be a difficult thing due to the fluctuation of support in email clients.
This list is very helpful for checking out what is supported and help guide you along the way.

Can I use a DIV in an email template?

I am greatly confused about designing an email template for a mailchimp campaign. I want to know if I can use a div with a class of "Container" on my email template. Is using div tags supported by all mail clients? I am using DIV only for the container but in the inner part of the template I have used table, tr and td tags. Please let me know.
Thanks.
You can use div, however tables are supported more consistently. If you try to go the div route, you'll find some of your CSS will fail.
Also, by going with tables, it opens up the old school html attributes that only work in tables. These include align, valign, bgcolor etc, all of which are 100% supported, while their CSS equivalents have partial support.
On a side note, here are all the resources you will need to get started in html email.
As of April 2017, yes, you can use <div> tags in email. Outlook was the only major email client that didn't support them.
See https://github.com/rodriguezcommaj/principles-of-email-design and https://www.sendwithus.com/resources/templates
There is no specifications for layout using table-less nor tables. However, using tables is the preferred way as it renders all at once. This aligns with how email templates render; while div's render separately. If you use div's include your css inline to the template as some clients do not support external css.

css style and inline style not working in outlook 2007

I have a html newsletter page. I need to send it to the given mail id. In Outlook , I'm unable to see the my styled html page but in browser css and inline style works perfectly. So why in Outlook does not work inline or Css style?
To get good cross-compatibility it's wise to go with last centuries web practices.
Use tables for structure, style inline, use pixel measurements and be prepared for images to fail.
These basics provide robust results in most clients.
Its best to also avoid background images since these wont work either in outlook.