{"id":2853,"date":"2016-04-06T11:02:26","date_gmt":"2016-04-06T11:02:26","guid":{"rendered":"http:\/\/freshinbox.com\/blog\/?p=2853"},"modified":"2016-04-15T07:32:21","modified_gmt":"2016-04-15T07:32:21","slug":"outlook-com-alters-styles-of-elements-next-to-checkboxes","status":"publish","type":"post","link":"https:\/\/freshinbox.com\/blog\/outlook-com-alters-styles-of-elements-next-to-checkboxes\/","title":{"rendered":"Outlook.com Alters Styles of Elements Next to Checkboxes"},"content":{"rendered":"<p>If there&#8217;s one thing you can count on in email, its that Outlook and Gmail will introduce quirks that frustrate email developers who are trying to innovate in email. Sometime over the past two weeks the new Outlook.com (including Office 365 Webmail) started introducing side effects to their processing of checkboxes in email. (Some old Outlook.com accounts are still <a href=\"https:\/\/blogs.office.com\/2015\/05\/21\/new-ways-to-get-more-done-in-outlook-com\">on the old UI<\/a> and don&#8217;t exhibit this behavior).<\/p>\n<p>Styles of elements following checkboxes are either removed or styles of checkboxes are being appended to the adjacent elements.<BR><BR><\/p>\n<p><H4>How Outlook.com Affects Code With Checkboxes<\/H4><\/p>\n<p>Outlook.com has always stripped checkboxes and form elements. What is new is that Outlook.com now inexplicably alters styles of elements following checkbox and radio elements.<\/p>\n<p>Note the following code:<\/p>\n<pre class=\"lang:default decode:true \" >&lt;input type=checkbox style=\"display:none !important;\"&gt;\r\n&lt;div style=\"width:400px;\"&gt;CONTENT&lt;\/div&gt;\r\n<\/pre>\n<p>In Outlook.com, the checkbox gets stripped and its style gets appended to the adjacent div.<\/p>\n<pre class=\"lang:default decode:true \" >&lt;div style=\"display:none !important; width:400px;\"&gt;CONTENT&lt;\/div&gt;\r\n<\/pre>\n<p>As you can see this results in the adjacent element being hidden! <\/p>\n<p>However, if you leave off the final semicolon (;) from the inline style in the checkbox, instead of copying the style to the next element, Outlook merely&#8230;. removes the style!<\/p>\n<pre class=\"lang:default decode:true \" >&lt;input type=checkbox style=\"display:none !important\"&gt;\r\n&lt;div style=\"width:400px;\"&gt;CONTENT&lt;\/div&gt;<\/pre>\n<p>becomes:<\/p>\n<pre class=\"lang:default decode:true \" >&lt;div style&gt;CONTENT&lt;\/div&gt;<\/pre>\n<p>Now we have the opposite problem. What if we styled the adjacent element to be hidden? By having the style stripped, the element is no longer is hidden.<\/p>\n<p>Its useful to know that if the adjacent element has no inline style, Outlook locates the next element that has an inline style and messes it up.<BR><BR><\/p>\n<p><H4>Handling the Outlook.com Bug<\/H4><\/p>\n<p><B>Note:<\/B><i> The option you choose may depend on whether your email service provider alters your code (see ESP section below)<\/i>.<\/p>\n<p>Firstly, you may not necessarily need to fix your code to deal with Outlook.com&#8217;s &#8220;side effects&#8221;. If your checkbox code causes the next element to be hidden in Outlook.com&#8230; but you have styled that element to be hidden anyways &#8211; no problem! <\/p>\n<p>But if Outlook.com&#8217;s checkbox quirks are wrecking havoc with your design, here&#8217;s how to deal with it.<BR><BR><\/p>\n<p><B>Option 1: Use a wrapper with a throwaway inline style<\/B><\/p>\n<ol>\n<li> Make sure your inline styles on your checkbox or radio element does not end with a semi-colon.<BR><\/li>\n<li> Put a throwaway standalone inline style in the element following the checkbox or radio element. If the following element already contains inline styles, place the throwaway inline style on a wrapper div.<\/li>\n<\/ol>\n<p>Instead of using a random style like <b>padding:0<\/b> for my throwaway style I&#8217;m going to use a fake vendor prefixed style <b>-outlook-checkbox-fix:1<\/b>. This makes it obvious why its there.<\/p>\n<p>So your checkbox code after incorporating <a href=\"https:\/\/freshinbox.com\/blog\/how-to-hide-checkbox-and-radio-in-email\/\">checkbox hiding methods<\/a> would look something like:<\/p>\n<pre class=\"lang:default decode:true \" >&lt;!--[if mso]&gt;&lt;!--&gt;\r\n&lt;input type=\"checkbox\" style=\"display:none !important\" checked&gt;\r\n&lt;!--&lt;![endif]--&gt;\r\n&lt;div class=\"wrapper\" style=\"-outlook-checkbox-fix:1\"&gt;\r\nCONTENT\r\n&lt;\/div&gt;<\/pre>\n<p>In Outlook.com, the code above would transform into:<\/p>\n<pre class=\"lang:default decode:true \" >&lt;div class=\"x_wrapper\" style&gt;\r\nCONTENT\r\n&lt;\/div&gt;<\/pre>\n<p><BR><BR> <\/p>\n<p><B>Option 2: Override the display property in the next element<\/B><\/p>\n<p>Thanks to <a href=\"https:\/\/www.jmweb.net\/\">Jeremy Martinez<\/a> for providing this tip in the comments below.<\/p>\n<ol>\n<li> Make sure your inline styles on your checkbox or radio element ends with a semi-colon <b>(Opposite of Option 1)<\/b>.<BR><\/li>\n<li> Override the display property with a visible property and !important in the next element. ( &#8220;display:block!important&#8221; for a div or &#8220;display:table!important&#8221; for a table)<\/li>\n<\/ol>\n<pre class=\"lang:default decode:true \" >&lt;!--[if mso]&gt;&lt;!--&gt;\r\n&lt;input type=\"checkbox\" style=\"display:none !important;\" checked&gt;\r\n&lt;!--&lt;![endif]--&gt;\r\n&lt;div style=\"display:block!important\"&gt;\r\nCONTENT\r\n&lt;\/div&gt;<\/pre>\n<p>In Outlook.com, the code will be changed to:<\/p>\n<pre class=\"lang:default decode:true \" >&lt;div style=\"display:none!important; display:block!important\"&gt;\r\n CONTENT\r\n&lt;\/div&gt;<\/pre>\n<p>As you can see display:block overrides display:none since it comes after it. However this div can not be hidden using the :checked pseudo-class or a media query (you cannot override an inline !important property with a non-inline !important property). If you coded the element so that its visibility is dependent on the state of the checkbox, the solution is to target a child element to show or hide instead.<BR><BR><\/p>\n<p><B>Email service provider(ESP) quirks<\/B><\/p>\n<p>As most of you know, most email service providers alter your code in some way &#8211; sometimes drastically. For example, if you&#8217;re using Campaign Monitor, the editor ensures that inline styles always end with a a semi-colon. So if you&#8217;re using Campaign Monitor, you&#8217;re stuck with Option 2. If your ESP does the opposite, then Option 1 is your only choice.<\/p>\n<p>The way you can figure it out is to send both Option 1 and 2 as a test and see which content blocks are visible in Outlook.com.<BR><BR><\/p>\n<p><H4>Other Outlook.com Quirks<\/H4><\/p>\n<p>The above bug is particularly gnarly if you&#8217;re experimenting with interactive email, so I hope you find the fix above helpful.<\/p>\n<p>However Outlook.com has other choice quirks as well and R\u00e9mi Parmentier has cataloged a <a href=\"https:\/\/medium.com\/@hteumeuleu\/what-you-need-to-know-about-the-new-outlook-com-8d2c54719398#.phbd938oi\">few of them<\/a>.<BR><BR><\/p>\n<p><H4>FreshInbox Examples<\/H4><\/p>\n<p>The examples in this blog has been modified to take into account this Outlook.com bug. However if you come across any issues with the examples with Outlook.com, let me know!<\/p>\n<p><BR><BR><BR><br \/>\n<div style=\"padding:10px; border: 2px solid #99C731;background-color:#FFF8DC;border-radius:5px;\">\n<form action=\"https:\/\/freshinbox1.createsend.com\/t\/i\/s\/adrmi\/\" method=\"post\" id=\"subForm\">\n<span class=\"fisub_header\" style=\"font-weight:bold;\">Subscribe to the #EmailGeeks Newsletter<\/span>\n<p><input id=\"fieldEmail\" name=\"cm-adrmi-adrmi\" type=\"email\" style=\"width:90%\" required placeholder=\"Your Email Address\" \/><\/p>\n<p><button type=\"submit\">Subscribe<\/button><\/p>\n<\/form>\n<\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometime over the past two weeks, OWA &#8211; Office 365 Webmail or the new Outlook.com started introducing side effects to their processing of checkboxes in email. Styles of elements following checkboxes are either removed or styles applied to checkboxes are being appended to these elements&#8230;<\/p>\n","protected":false},"author":2,"featured_media":1766,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23,24,25,47,46],"tags":[],"_links":{"self":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts\/2853"}],"collection":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/comments?post=2853"}],"version-history":[{"count":26,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts\/2853\/revisions"}],"predecessor-version":[{"id":2885,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts\/2853\/revisions\/2885"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/media\/1766"}],"wp:attachment":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/media?parent=2853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/categories?post=2853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/tags?post=2853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}