GV
6
Gap Under Images on Office 365 and Outlook.com
Hello everyone!
I've for a few days strange lines that appear under my images on Office 365 and Outlook.com. However, I've a display: block on my pictures, and, strange thing, everything is ok when I do a test in real! This bug appears only on Litmus or Email on Acid. When I add a style = "font-size: 0px" to the cell containing my image, the problem is fixed ... But why? Do you have an explanation? I would like to understand this fix, and not add it to my code without reason ...
Here is my code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Document sans titre</title>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FFFF00"><img src="http://test.badsender.com/BADSENDER/R&D/images/visuel_01.jpg" width="600" height="400" border="0" style="display:block; font-family:Arial, Helvetica, sans-serif; font-size:20px; color:#000" alt="test01"></td>
</tr>
<tr>
<td bgcolor="#00FFFF"><img src="http://test.badsender.com/BADSENDER/R&D/images/visuel_03.jpg" width="600" height="200" border="0" style="display:block;"></td>
</tr>
<tr>
<td bgcolor="#FF00FF"><img src="http://test.badsender.com/BADSENDER/R&D/images/visuel_02.jpg" width="600" height="400" border="0" style="display:block;"></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
So it appears an update was shipped where Outlook.com/Office 365 introduced the ability to click on non-linked images to "view" them within the email as standalone assets, just like Gmail does.
In doing so, any non-linked image is wrapped with a
<button>
tag. All images - regardless if linked - are wrapped with<div style="display: inline-block;">
.A few recommendations:
display: block;
on your image tags (either inline or embedded CSS) if desired behavior<button>
functionality<div style="display: inline-block;">
wrapper, then wrap the<img>
tag in its own<div>
with a class i.e.which gets processed by Outlook.com/Office 365 to:
and just target that
<div>
with CSS:Thanks Kevin!
Just wanted to add, in relation to #2 above, using href="" or leaving href out of the anchor tag completely will result in Outlook.com removing the entire anchor tag and adding that button tag in. The href needs to be there and something needs to be in it. Just in case anyone had the same thought that I had and spent hours testing hah!
Hi Kevin, thanks for this answer! Did you know when exactly Outlook.com/Office 365 made this update? And whyyyyy?? :D What is the advantage of viewing these images outside the email?
Thank you anyway for your recommendations, but I still have a question:
And a last one: why only on Litmus, but not in real test?
I don't know why Microsoft insists in sabotaging their own products. However, regarding your last question, it seems like I don't have this update with my french account. So this update may not have been deployed for every Outlook.com users yet, which might explain why you see the bugs on Litmus but not in real tests.
Actually you don't need to link the images if you set 'button' to display:block as well
Also: First! :P
Solved this two months ago: https://litmus.com/community/discussions/6170-how-to-remove-space-under-an-image-in-hotmail#comment-10454
Put this in your head styles to resolve:
div,button { margin:0 !important; padding:0 !important; display:block !important; }
This is the fix for me! The others whilst working in part, didn't fix the render issues I was having in Safari.
The "download" button still gets applied to images of a certain size (just like gmail) but at least you don't have to apply real hrefs to every structural image - I just created a template using side slithers to allow for flexible heights but needed 1px wide images and bgcolors to achieve the design - you can imagine the render issues this was causing.
Great job with the fixes guys :))
Thanks so much for this! I was having a huge battle with rendering in Safari, this did the trick
Thank you! This is working great for my emails as well.
Nice one Brian! Seems like to most elegant fix atm.
Should also mention, those using fluid/hybrid layouts with side-by-side <div>'s, you'll want to do something like this:
div,button { margin:0 !important; padding:0 !important; display:block !important; }
.ib { display:inline-block !important; }
and assign class="ib" to those <div>'s.
Works for me... Thank you so much! Great job figuring this out, it was driving me crazy...
I found adding
[office365] button {display: block !important; }
in the style block, which will target Outlook.com only and override the style being injected, will resolve this.I found this works for me as well, just targeting the div wrapping the button doesn't work in Outlook.com, gotta target the button too!
I'll do the same with [office365] div, and it will be perfect! Thanks!
Yup, that's what I ended up doing too.
Thanks a bunch to you both!
Couldn't use the div declaration without [office365] because our editor uses divs. With it, it works like a charm.
Hi All,
I was reading about this during my morning commute.
Use this:
div{ display:block !important;}
I found this over at the monks feed.
Cheers
Thanks, i added this line in the head and it works fine!
Hey Shameer,
Thanks fro spreading words, we are glad to known that it is helping emailgeeks!
Regards,
Kevin
No problems Kevin. I tried linking to the article by the monks but something went wrong. I love the work u guys do there ;-)
After looking into this a little bit, if your images are contained within table cells throughout your email, it seems like you can set the all the
<td>
tags tofont-size: 0;
in your<style>
block in the header of the email. This will remove the space and can easily be overwritten by inlining font sizes when needed. Since I already inline all of my text formatting, this seems to be the easiest solution for me. I also haven't noticed any unwanted changes in any other email/Webmail client.this is what worked for me to fix space under image issues in OL 2013 / 2016 / 2019
td { font-size: 0;}
Has Outlook.com removed this 'feature' (as of 5/16/17)? I just tested an email in outlook.com and the non-linked images are no longer clickable and no longer pop up as a preview. Images are no longer being wrapped in a <div> and <button>.
Has anyone else experienced this?
Yes. I officiallly got word from people on the Outlook.com that this feature was removed after my article. The update that removes this feature is rolled out for 99% of Outlook.com users (and the rest should follow slowly). So it's safe to assume we shouldn't bother about hacks regarding this bug.
Now that is a result. Great work Rémi!
Just confirmed it rolled out here. Excellent work uncovering the underlying issue!!!
!!! It's gone for me too!!! No more divs and buttons and other shit :-O
It might be a slow roll out at the moment if that's the case. Mine is still showing the <div> and <button> wraps in both Outlook.com and Office365.
Hi, I have the same problem... The only thing i found is that Office 365 and Outlook.com add a div with style inline-block arround the image... How to remove it, i haven't figured out...
I findout the same. I made a workround, I wrote a CSS:
#wrapper div { height: inherit !important; }
And add height to containing td. The #wrapper ID is added to second table which is wrapping whole content of e-mail, I don't want to add this to all div's in webmail for example.
Sounds like a sollution for static mails only right? I think for Grégory Van Gilsen it is a fix. For scaleable responsive mails not.
Well when I put only div { display:block !important; } it didn't work for not linked image(because it is adding a button tag to them), I just simply do it this way: div,button { display: block !important; }
Now works fine. Of course there is a warning here - because you need to be carefull when you are using DIV in your code for other purposes.
What a good idea! And it works fine! However, does it not risk to bring other rendering problems on other webmails?
@Grégory
If you are afraid of interfering your CSS with web mail, you can always do it this way:
#wrapper div, #wrapper button {}
Which will work only on div and buttons inside your wrapper table (ot if you call it another way, you need to use your ID).
PS. I cannot answer directly to you.
It is, when you are using only media queries, and in this design I was using only them.
As far I remember I tried display:block and it didn't help on Outlook.com Firefox Windows 8, I will try it later and let you know.
Hello Grzegorz. Thanks but this fix seems not to be "ideal" for a responsive email...
If Outlook.com and Office 365 add it automatically (according to Kevin's explanations), I think that we can't remove it.
Have you tried putting these inline codes on TD of the images: font-size: 0px; mso-line-height-rule: exactly; line-height: 0px;
Thanks to everyone who's posted on this thread, this update has been especially frustrating for me because it broke several different layouts I use. I found the solution for me was slightly different what others posted here. I also found that Safari on Mac for outlook.com / office365 required some extra code that firefox / chrome did not.
I had trouble targeting the <button> and <div> that outlook.com is adding. I'm using the spongy / hybrid coding method and I use Litmus to inline my CSS and since the <button> and <div> do not yet exist in the code I had to use a separate style tag with data-ignore-inlining to successfully target the offending code. The font-size and line-height were continuing to cause the gaps in my tests, so I ended up with this code where .enclosing-td-class is the class name of the parent <td> (I went this route instead of wrapping the image in another <div> as suggested by Kevin Mandeville):
<style data-ignore-inlining>
button { font-size: 0 !important; }
.enclosing-td-class div { display: block !important; }
</style>
I also had to set font-size and line-height to zero in the enclosing <td> tag to completely get rid of the gaps in all browsers.
I really appreciate the community here, I wouldn't have gotten this fixed without the great input from everyone else.
Last time I used this in early March, it worked for me:
<td align="center" valign="bottom" class="hide"><div style="height:HEIGHTpx; font-size:0;"><img src="YOUR-IMAGE-HERE" width="WIDTH" height="HEIGHT" align="textbottom" style="display: block; font-family:Arial,sans-serif; font-size:12px; line-height:16px; color:#333333; border-style:none; text-align:center;" border="0" class="hide" /></div></td>
Basically, I wrapped the IMG inside a DIV that has an inline style of "height:XXXpx; font-size:0". Then at the IMG level, style it so there's no border AND make sure to include attribute align="text bottom". Hope this still works.
Shameless plug in can anyone stumbles here. I found another solution that consists in adding an id that starts with
OWATemporaryImageDivContainer
on all your<img>
tags. You can read more about this here.Thanks its work
Wow. Hell of a search. Thanks.
Do the id's need to be unique? I know it's best practice, but i've been using id's in my mediaqueries which i place in more then one place in my html. Haven't had any problems in mailclients.
Have you tried putting these inline codes on TD of the images: font-size: 0px; mso-line-height-rule: exactly; line-height: 0px;
Alright, so we know outlook.com adds a div (and a button if the image isn’t linked) around images.
That div inherits a font-size of 15px from somewhere in the outlook.com stylesheet:
._rp_o5 {
font-size: 15px;
}
Which result in a 4px empty space below the image. Which we don’t want, because some images should align against another element.
As a fix I thought I could create the reset:
div { font-size: 0;}
As all text in our code always has font sizes set this wouldn’t be a problem. However, the mail tool we’re working with adds a div around text if you click the alignment option in the editor <div style=“text-align: center;”> </div>.
So suddenly text that is centered disappears because the font-size is set to zero in the stylesheet. As the editor doesn’t add the font-size or line-height to that tag.
Is there anyway to only set the font-size to zero for divs that include an image? I googled but found no solutions.
Or maybe you guys know of a different way to target those specific divs and leave the others alone.
Hi Marjolein,
Here's what I have for our emails.
div, button{
display: block !important;
}
or
div, button{
vertical-align: bottom;
}
Well I'll recommend use vertical-align as it won't affect a lot to the text (literally no) and usually we don't add that property (so we don't need to add !important, which may override some inline styles)
But if you use vertical-align, please make sure your image is bigger than 15px*1.3 line height. The reason that cause this issue is because the image is wrapped with an inline block div in Outlook.com which literally regardless the "display: block;" on the image. So it's actually because image aligned to the baseline, and there's always a gap between baseline and bottom line.
Let me know if that makes sense to you.
Woody
Thanks that works!
I don't really get why putting the display block on the div makes it ignore the font-size, but it works!
Because font-size is only for the inline / inline-block elements. Even if it's set on the block level elements, it only affects the inline / inline-block elements inside that block elements.
Sorry I misunderstood your question. But the reason that font-size won't work is because of the priority of the CSS selector, element selector (div here) has lower priority than the class selector (._rp_o5). So 15px won't be overridden by "0". You may need to add
!important
on your style to lift the priority of the style. But that will override any font size in any div in your email.My team and I have run in to this issue as well. While we have found two methods of circumventing the issue, we do not understand why Outlook.com is now behaving this way.
In addition to the <div style="display:inline-block"> being applied, I also noticed that unlinked images are being wrapped in button tags. What's even more odd is some of the buttons in the same email are disabled while others are not.
Enabled:
<button type="button" class="_at_6 o365button" aria-labelledby="_ariaId_1170"><img src="…" alt="" width="600" height="168" class="x_hide" style="display:block; border:0"><span class="_fc_3 owaimg" style="display: none;"> </span><span class="_fc_4 o365buttonLabel" id="_ariaId_1170" style="display: none;"></span></button>
Disabled:
<button type="button" class="_at_6 o365button" aria-disabled="true" aria-labelledby="_ariaId_1177" disabled="true"><img src="…" alt="" width="600" height="49" class="x_hide" style="display:block; border:0"><span class="_fc_3 owaimg" style="display: none;"> </span><span class="_fc_4 o365buttonLabel" id="_ariaId_1177" style="display: none;"></span></button>
Very strange.
Hello Jeremy. We are getting used to "strange" with Outlook, but there... WTF!!!! ;)
Hi Grégory,
I have try to resolve your challenges, kindly use below code.
let us know any other queries,
Thanks
Kevin
Hi Kevin,
I tried your solution and my Litmus test looked fine. However, when we sent the email out that spaces still show up.
Also, could you explain how just adding "div" to style fixes this issue?
Thanks!
Curious to know if you're using Builder to "test" your email vs. sending a test directly from your ESP? My experience is, for the most part, Builder seems to render HTML like a browser. I believe you can get a more accurate result if sending the test directly from your email platform.
Hi Jamie,
Right away, Outlook is updated and it's added automatically DIV tag before image tag, and that DIV automatically taken some line-height, so it's shown the gap in below.
So, If we are adding style in HEAD and its inherit that DIV tag, hence it's not appears gap below the image.
Let me know if any other uncertainties.
Thanks
Kevin
Hey Kevin,
Thank you for explanation. Unfortunately, your solution doesn't work by itself. As I said the test looks good on Litmus but when we send a live test it still breaks on Outlook.com and Office 365. It took me 3 days but I solved this. But I am not sure if this going to work on everyone's emails.
• All
<img>
tags have to havestyle="display: block; font-size: 12px; line-hight: 12px"
– Otherwise alt text will not show up.Exp:
<tr><td align="center"><img src="images/image.jpg" width="100" height="100" alt="" style="display:block; font-size: 12px; line-height: 12px; " border="0" /></td>tr>
• All spacing
<td>
tags have to havestyle=" font-size: 1px; line-hight: 1px"
Exp:
<tr> <td height="5" style="line-height:1px;font-size:1px;">nbsp;</td> </tr>
If anyone uses
“<div style="white-space:nowrap; font:15px courier; line-height:0;"> ---- </div>”
on their HTML file. They need to add “gmailfix” class to style.Exp:
I hope these solutions help everyone.