MSO-specific CSS hack for Outlook HTML email? - html

There's a ton of IE conditional hacks (such as ending a style property with !ie, various uses of the * character, etc.).
I tried several of these in an inline style in an email sent to Outlook (2013), but they did not appear to work.
I tried mso-width-alt:100% but what little documentation I can find doesn't show it supporting percentages.
I also tried !mso just to see if it did anything, but it did not.
I'm wondering if anyone knows of any CSS hacks that can be used for Outlook/MSO inline styles?
More specifically, I have a table that needs to be width:100% in Outlook, but breaks in iOS so I'm using min-width:100%, which doesn't work in Outlook. I know I can wrap the table tag in a conditional and swap it out completely to make it work, but I'm trying for a more elegant solution if one exists.

Prepend property with !
<table style="!width:100%"></table>
Appears to affect MSO and IE<=7 only:
I am going to have so much fun with this.

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.

When designing HTML templates for emails, what should i know [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
When implementing an HTML template that will be sent in an email, what should I know? For example, I know most email clients do not download images by default. How do you get around that? What are other css/html implementations that are not supported?
The first thing as a rule of thumb is: When you code HTML emails, code like you're back in the 90s. That is: Table layouts!
Wrap everything in a Table widh
border="0" cellspacing="0" cellpadding="0"
CSS is supported in some mail clients, others fitler it completely. Some clients only allow inline-styles, not style tags. So it's best to still use <font> tags for text styling and the deprecated bgcolor attribute, and so on. Padding/margin around elements should not be generated using CSS padding and margin, but rather by using empty table cells that include a transparent 1x1px gif. Make sure to apply the height to the img tag as well as the td and if you really want to make sure, also the tr tag.
Things are getting better and better, with Gmail recently making changes that allow media queries for responsiveness, but that has not rolled out globally yet.
So with media queries not (yet) working everywhere and most people using mobile devices nowadays, it's not a bad idea to use a "mobile-first" approach and use media queries on larger displays to extend the layout. For Outlook, you can use conditional comments (as it doesn't support media queries either) to achieve the same:
<!--[if mso]>
<style>/* style block will only be used in MSO */</style>
<![endif]-->
where you are also able to target specific Outlook versions, for example the current Windows 10 Mail app is mso 16. You can use lte/gte/gt/lt just like in conditional comments used for old IEs in earlier times.
Speaking of Outlook: It's also a pain in the ... eye in some other areas. To force line-height and prevent some unwanted spaces, there are MSO-specific styles like mso-line-height-alt:0; and mso-margin-top-alt:1px;, I recommend reading up on these as well.
For column layouts, do not use float, but align="left" on each table that represents a column, except for the last table in a "row" (because that will cause problems with tables floating off the grid in Thunderbird).
In my experience, at least if you're starting a template from scratch, it's a matter of building, testing in clients (webmail, desktop and mobile devices), fixing, doing research about some client-specific things that don't look the way you'd like them, trying out some own attempts to fix it, and testing all over again.
Email clients and rendering engines
Email clients use different rendering engines to render HTML emails:
Apple Mail, Outlook for Mac, Android Mail and iOS Mail use WebKit
Outlook 2000/02/03 use Internet Explorer
Outlook 2007/10/13 use Microsoft Word (yes, Word!)
Web clients use their browser’s respective engine e.g. Safari uses WebKit, Chrome uses Blink
Update November 2016: Just recently Google announced support for embedded CSS and media queries in Gmail. This is HUGE for the email development industry. Now, as of September 2016, Gmail will support a slew of CSS properties which makes template development a lot easier for Gmail.
Litmus has a handy website dedicated to the current email client market share, based on their own internal stats (~1 billion emails).
font: http://www.leemunroe.com/building-html-email/
I suggest to you use and test these ones:
https://github.com/TedGoas/Cerberus
http://foundation.zurb.com/emails.html
http://litmus.com/
https://www.campaignmonitor.com/
I hope this helps you.
You can't link any external stylesheet, You cant use floats, some clients ignore background images. Your should check out foundation for email if you wish to use good looking html emails in your projects that most clients support. There are several default templates available that you can use or you can build your own custom designs.
There is a lot you need to know, but a few big ones that comes to mind are:
Use table based layout
Use HTML4 syntax
Use CSS2 syntax
Use inline css (style=) and do not include a style tag in the head
Use alt text for all images and use a background color as a fallback when the image hasn't been downloaded yet.
Those are just a few pointers, but I agree #Joseph Marikle, refer to the link he posted.

Is it possible to apply Z-index using HTML?

I have a long vertical email form that I am editing from an old template made out of tables and the widths don't match up perfectly all the way down so what I intend to do is add a div or image etc behind all the tables so it is just wider than the widest table and it will hide the messy table layout and make the email form look unified and neat.
I've done a similar thing in the past but using z-index on CSS. As I am sending this to Outlook I don't want to use CSS.
Sorry if my post is confusing. Any help appreciated
The short answer is NO, it is not possible to do that with HTML only unless and until you are willing to change the order of your markup, else as far as the CSS goes, you can use z-index inline for that particular element.
So for example
<div style="z-index: /* Whatever */"></div>
While it is true that inline styling works across all major modern mail clients, z-index does not. I'm sorry to have to say this, but you're probably gonna have to rebuild your nested tables from the ground up if their sizes don't match.
As a quick example: Outlook 2007 uses word as a rendering engine. z-index will never display with that client, therefore will completely break your layout. And a lot of people still use outlook 2007, like it or not.
If you need some layering effects, you'll have to use plain old images and cut those so they fit in table cells. It's a pain, but that's part of the html-email world, and that's probably what you are being paid for.
You can use inline CSS. This works in outlook and all other email clients.

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.