Proportionate html images in Outlook - html

I have a number of different sized images which I am trying to resize and make proportionate with one another using css width and height attributes on <td> elements, and then making the width and height of the actual images 100% of this <td> element.
I am then trying to use this code in an e-mail campaign. The problem is this code works correctly, as expected, but outlook still seems to render the images with their original width and height values.
Does anybody know how I can prevent this from happening.
Note: I have removed the image src and links from my code.
<table width="100%"> <!-- a width 100% container -->
<tr>
<td></td> <!-- an empty cell, which will adapt its width -->
<td width=250 height=300> <!-- it's like max-width:200px -->
<a href="SOME LINK">
<img width="100%" height= "100%"src="SOME IMAGE LINK" alt="Just for you" title="Just for you" />
</a>
</td>
<td></td> <!-- another empty cell, which will adapt its width -->
</tr>
<tr>
<td></td> <!-- an empty cell, which will adapt its width -->
<td width=250 height=300> <!-- it's like max-width:200px -->
<a href="SOME LINK">
<img width="100%" height= "100%"src="SOME IMAGE LINK" alt="Just for you" title="Just for you" />
</a>
</td>
<td></td> <!-- another empty cell, which will adapt its width -->
</tr>
</table>

Outlook is wonky. It renders via WordHTML, which is silly.
The issue is that without a defined value in the HTML attribute, Outlook views 100% as the total width of the actual image (and sometimes even larger if the resolution of your desktop is different from the resolution of the image).
Your best bet is to either set media queries to change width/height to 100% once it reaches your desktop break point, or to do something even wonkier, like below:
<img width="640" height="240" src="SOME IMAGE LINK" style="width:100%; height:100%" />
You just replace the 640 and 240 properties with the height and width you want your image. The rational behind this is that the vast majority of email clients respect the proper waterfall and place CSS above HTML attributes, but Outlook, like the silly goose it is, will actual ignore the 100% CSS and work based off of the declared HTML attribute.
Now this is not a 100% foolproof message and should be tested extensively.
Your final solution, if nothing else works is to actually resize the original image to the maximum size you want it to display in Outlook.

Related

Yahoo changes width to min-width on td

Sorry, not 100% certain if this belongs here or Super-User group but...
I have an html email, with 4 icons that I want centered and slightly spaced.
So, I have a table with 4 set width cells and an extra empty one on either side.
<table style="width:100%;border-collapse:collapse;table-layout:fixed;">
<tr>
<td></td>
<td style="width:32px;padding:0 4px;"><a><img src="" /></a></td>
<td style="width:32px;padding:0 4px;"><a><img src="" /></a></td>
<td style="width:32px;padding:0 4px;"><a><img src="" /></a></td>
<td style="width:32px;padding:0 4px;"><a><img src="" /></a></td>
<td></td>
</tr>
</table>
Works in every email client in every browser I've tested (mostly using Litmus) except for Yahoo.
Yahoo is replacing the "width" declaration with "min-width" across all browsers, which is breaking the layout.
I've tried adding width:32px;min-width:32px;max-width:32px but it has the same issue.
Any workarounds or explanations?
Quick fix, place this in your <style> tag: #media yahoo {min-width:0!important}
This change/bug is brand new at the time of this posting. Yahoo is now changing width to min-width, breaking hybrid layouts among other things. There is a good discussion about other hacks in the Litmus Community.
I faced the similar problem with height. Yahoo email client automatically converted height to min-height.
As a fix to this problem, I added height="300px" as an attribute to the tag.
This helped me to solve the issue.

Basic HTML table formatting for email

I am making a simple newsletter layout that can only contain basic HTML but am getting caught up on formatting it properly. I have very little html experience, if I could use css I could lay this out but this is meant to be low level html that most e-mail clients can display properly.
This is a bit of code that I've done to get the image and a button (in the position of button 2) looking correct but it's getting the top and bottom buttons sitting there correctly that's the issue.
<table width="100%" style="text-align:center;">
<td>
<img src="http://localhost/temp/leftpic.png"></td>
<td>
<img src="http://localhost/temp/button.png"></td>
</table>
This is my design outcome. With the outter border being a table border centered in the middle of the page.
Is it possible to format something relatively close to this without using css?
I appreciate any help, cheers.
You CAN use css, you just have to avoid third-party files. You need to define the CSS rules inline, that is, in the style attribute, as you are already doing it for table. However, your HTML is invalid. You need to have tr elements outside your td elements and it is healthy to actively wrap your tr elements inside a tbody, which should be the child of your table.
By the way: the reason one should avoid third-party css in this case is that it might mess the design of the page of gmail/yahoo.
Something like this will start you off... This is with no CSS and no styling (other than what you have originally).
Although you state no CSS yet your first line is styling (albeit inline). Did you just mean no external file?
This is how we used to do layout before CSS, so this is using HTML tables:
<table width="100%" style="text-align:center;" border="1">
<tr>
<td width="50%">
<img src="http://localhost/temp/leftpic.png" width="390" height="480" />
</td>
<td>
<table>
<tr>
<td><input type="button" value="bn1" /></td>
</tr>
<tr>
<td><input type="button" value="bn2" /></td>
</tr>
<tr>
<td><input type="button" value="bn3" /></td>
</tr>
</table>
</td>
</tr>
</table>
Since you have a fixed height of your image on left, you can also use
<tr height="160">
Since 160 * 3 = 480 (the height of your image)
See an example here https://jsfiddle.net/on6ytfyn/
You probably want to remove the border in the first line of code too.

Adjusting iframe within table

I need advice on a simple exercise I am trying to do - I do not code to html UI usually.
The following code attempts to load 2 iframes within table cells:
<html>
<body>
<table border="1">
<tr>
<td>
<div id='outerdiv '>
<iframe src="book.jsp" id='outiframe' scrolling=no >< /iframe>
</div>
</td>
</tr>
<tr>
<td>
<div id='summarydiv '>
<iframe src="book-view.jsp" id='inneriframe' scrolling=no >< /iframe>
</div>
</td>
</tr>
</table>
</body>
</html>
Obviously additional attributes have to be added to make the 2 iframes visible.
Currently,IE8 shows the iframes horizontally placed beside each other,with neither displaying in full.
Firefox only displays the top one.
What is the minimum basic template needed here to make the 2 iframes adjust and be visible together - and resize well with the browser size.
The problem is that your closing iframe tags have a space in them
< /iframe>
Should be
</iframe>
No need to add extra div tags. give the id 'outerdiv' and 'summerydiv' to TD and set css style max-height and max-width.
It may able to hold your iFrames in position.

Html email Template <td> Spaces around images

I am coding html email template , I did slice psd to html because of graphical work in template , now problem is that it looks perfect in my browsers but when I send it to my email id there are some problems that you can see in attached image
now this is <tr> with 3 <td> but problem is that there is gap between left blue image and logo right one is perfectly fine , code for this <tr> is:
<tr>
<td colspan="2">
<img src="left.jpg" alt="top_left" width="220" height="102" border="0">
</td>
<td colspan="2">
<a href="http://www.google.com">
<img src="logo.jpg" width="191" height="102" border="0" alt="Logo"></a>
</td>
<td colspan="3">
<img src="right.jpg" alt="top_right" width="200" height="102" border="0">
</td>
</tr>
Please let me know how I can fix it.
Also, make sure to always use this style on your images : display:block;
Some mail clients will do whatever they want with your code (Looking at you, gmail), and unless you specify that your images are rendered as block elements, it will add white spaces around those.
There are a couple of important fixes for gmail. Black links should always be colored as #000001 (gmail removes the black color on links, as well as on regular text for redundant content in conversations (It will turn this text purple when reposted unless you specify that the text color is #000001) ).
Also, make sure you use inline styling for your TDs height and width, sometimes the regular html value won't do.
Remove whitespace after a tag. Also make sure table have cellspacing, cellpadding and border set to 0. You might need to remove all whitespace in cells.
E-mail browsers are a mess. Much more then IE6 was ;-).
It may be an easier solution to just to use a single image if keeping the line together is important.
Unless you know what e-mail user agent each recipient is going to be using to view the e-mail, it is difficult to target them in the manner that you proposed. Each e-mail client may use a different renderer, causing them to display the whitespace incorrectly. There are times, when using older e-mail clients, that you will need to remove ALL spaces and linebreaks to get table-based formatting to display correctly; this means having all of the HTML on a single line.
Also, keep in mind that if your recipients are viewing the content in HTML5, the border attribute of the img element is obsolete; it is instead correct to add style="border: 0;" to the img element. You may want to try using style="margin: 0; padding: 0; border: 0;" on the table cells and rows.
Make sure that you have your table set to collapse as well, using
<table style="border-collapse: collapse;">

HTML td background image not displaying

I have my table with <td>s. This <td> contains a background element which is not displaying.
Below is my HTML table.
<div class="left">
<table cellspacing="0" cellpadding="0" border="0">
<td class="displayroundtable"></td> <!-- for displaying background image -->
<td><img src="<?php echo $this->static_address;?>images/MAX-RATING-100.jpg"></td>
</table>
In the CSS,
.displayroundtable{
background-image:url('<?php echo $this->static_address;?>images/2321.png');
}
I don't know why my background image never gets displayed?
Make sure there is a width set on your empty cell, or else it will end-up at 0px thus not displaying anything. Also make sure that the browser renders the empty cells using the CSS rule empty-cells:show on the table.
http://www.w3schools.com/cssref/pr_tab_empty-cells.asp
The table needs TR to be standard compliant. I don't think it is the reason why your background is not displaying but make sure you surround your lines between <tr> .