I need to make a table-based layout and made my table width 550px. And then I loaded an image with original width of 550px but on browser I only have 449px. I want to make in on full width. And also I have extra space between cells.
<table style="width:550px;margin:0 auto;" cellspacing="0" cellpadding="0" border="0">
<tr style="margin:0; padding:0;">
<td style="font-size:12px; line-height: 12px; width: 100%; text-align: right; color:#5A99B1;">Click <b>here</b> for the online version</td>
</tr>
<tr>
<td style="width:100%; height:10px;" cellspacing="0" cellpadding="0">
<img style="width: 100%;" src="border-top.png" />
</td>
</tr>
<tr>
<td style="width:50%; background-color:white;">
<img src="brugadalogo.png" />
</td>
<td style="width:50%; background-color:white; text-align: right;">
<img src="msdlogo.png" />
</td>
</tr>
</table>
Your table columns are not uniformly even. You have 3 rows, the first 2 have 1 column and the last one has 2 columns. Even if you have the right percentages, it is better to have it distributed evenly. Such as have all 3 rows have or "take the space of" 2 columns.
What I mean by that is that instead of using widths, you should use colspan. Also remove the width from the image, if you want its original size, it should get it by default.
<table style="width:550px;margin:0 auto;" cellspacing="0" cellpadding="0" border="0">
<tr style="margin:0; padding:0;">
<td **colspan="2"** style="font-size:12px; line-height: 12px; text-align: right; color:#5A99B1;">Click <b>here</b> for the online version</td>
</tr>
<tr>
<td **colspan="2"** style="height:10px;" cellspacing="0" cellpadding="0">
<img src="border-top.png" />
</td>
</tr>
<tr>
<td style="background-color:white;">
<img src="brugadalogo.png" />
</td>
<td style="background-color:white; text-align: right;">
<img src="msdlogo.png" />
</td>
</tr>
</table>
Hope this solves your issue.
Related
What is the correct inline css to move text or an image center in Outlook. Any time I open it in a browser, it looks great but the bottom image and text always stay left in Outlook. Not sure what else to try. Any help is appreciated
<table cellpadding="0" cellspacing="0" border="0" width="800" align="left">
<table align="left" width="800px;">
<tr width="800px">
<td><img width="800px;" src="images/ArlingtonPic-edited.png"></td>
</tr>
</table>
<table align="left" width="800px;">
<tr width="800px">
<td width="800px" style="font-size:20px; margin-left: auto;
margin-right: auto; text-align: center; vertical-align: middle;">
<strong>Arlington Concrete Floor Boxes</strong></td>
</tr>
</table>
<table align="left" width="800px;">
<tr width="800px">
<td width="350px" style="font-size:16px; padding: -10px 10px 0 10px;">
<p>Our NEW heavy-duty<strong>FLBC4502</strong> 4.5"<strong> concrete floor
box</strong> has more! <strong> <span style="color: red">SIX conduit hubs and FOUR plugs.</span></strong>
And the NEW FLBC4502LR leveling ring makes
installation easier than ever on our FLBC4500
and FLBC4502, and others concrete boxes. <br>
It is <em>REVERSIBLE!</em></p>
</ul>
</td>
<td width="350px" style="font-size:16px; padding: 0 10px;">
<p>The screw holes on SIDE A fit all 4.5" boxes,
and accommodate our 6" round covers,
and most others on the market.
SIDE B features a second set of holes
that fit a cover with a 3-3/8" hole pattern.
These Arlington <strong>cover kits</strong> fit
our concrete boxes. <br>
<em>That is convenience!</em></p>
</td>
</tr>
</table>
<table align="left" width="800px;">
<tr width="800px">
<td width="800px" style="margin-left: auto; margin-
right: auto; text-align: center; vertical-align: middle;">
<img src="images/ArlingtonLogo.png">
</td>
</tr>
</table>
On your table cell use following attributes:
<td valign="middle" align="center">...</td>
for vertical and horizontal align.
This will add image in center in outlook.
<table width="100%">
<tr>
<td align="center">
<img src="https://4de5ad3168da.png" align="middle" width="200" height="130">
</td>
</tr>
</table>
http://imgur.com/a/fKv2H
I need banner with height 100px. and img inside it with height 120px. So the picture comeee out my banner for 20px;
Its for emails.
Also i need text column right before picture, so that text in column with background f4f4f4
<table>
<tr>
<td>
<img src="" style="margin-top:-20px;" />
</td>
<td>
banner text here
</td>
</tr>
</table>
You can do this two ways, one involved slicing the image into two and the other is using two more tables. I have added the code below for you to decide which one you want to go with.
Option 1:
This option has the image as one piece sitting in an outer table with 3 columns. The outer two columns have a table with white background to cater for the heads/hats popping out of the grey area. I have set the table width at 100% to show it will look.
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" bgcolor="#f4f4f4">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td bgcolor="#ffffff" style="height: 23px;" height="23"></td>
</tr>
</tbody>
</table>
</td>
<td width="171" valign="top"><img src="http://i67.tinypic.com/sdk1hh.jpg" width="171" height="178" style="display: block;"></td>
<td valign="top" bgcolor="#f4f4f4">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td bgcolor="#ffffff" style="height: 23px;" height="23"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
Option 2
For this option, you will need to slice the top part of the image (with white background) and place both the images in one table with two rows. Both images are centered and I have set the table width at 100% to show it will look.
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center" valign="top" bgcolor="#ffffff"><img src="http://i64.tinypic.com/lz7f6.png" style="display: block;">
</td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#f4f4f4"><img src="http://i68.tinypic.com/4qo1mu.png" style="display: block;"></td>
</tr>
</tbody>
</table>
The final outcome for both codes should look like this:
Let me know which option best suits you.
** UPDATE **
Your question asked if you can have option 1 with image to the left and text on the right, here is the example:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="171" valign="top" style="padding-left:20px;"><img src="http://i67.tinypic.com/sdk1hh.jpg" width="171" height="178" style="display: block;"></td>
<td valign="top" bgcolor="#f4f4f4">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td bgcolor="#ffffff" style="height: 23px;" height="23"></td>
</tr>
<tr>
<td style="font-family:Arial; font-size:12px; color:#000000; padding:5px 10px;">This is some text for your email</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
I added colors so you could see that it was outside the table. I gave the image a height of 120px, width of auto. Made the td's have a max-height of 100px; And I left your -20px margin on the image.
<body style="background-color:pink">
<table style="background-color:orange;">
<tr>
<td style="max-height:100px; overflow-y:initial;">
<img src="https://i.imgur.com/ZESO4DT.png" style="margin-top:-20px; height:120px; width:auto;" />
</td>
<td style="max-height:100px;overflow-y:initial;">
banner text here
</td>
</tr>
</table>
</body>
I tried searching for solutions in stack, but none of the answers I found addressed my issue.
I'm developing an email and I want to have a single cell row that has text with an image in between the text. The cell height is the full height of the image, but I want the text to be vertically centered. The text is now flush on the bottom
Here's my code (there's many inline styles, I apologize in advance). Please note this a single column row that is part of the fluid hybrid approach by Nicole Merlin.
<tr>
<td valign="middle" bgcolor="#e2f4ff" style="padding:0">
<table width="100%" align="center" border="1" style="border-spacing:0;font-family:sans-serif;color:#333333;">
<tr>
<td valign="middle" style="vertical-align: middle !important;;padding:0;text-align:left;padding-bottom: 5px !important;color: #17a0ce;font-weight: bold; Margin:0;font-size:26px; text-align: center;">
THE<img src="http://www.waldenway.com/wp-content/uploads/2015/12/largedog.png" alt="ABC's" /> OF SAFE SLEEP FOR DOGS
</td>
</tr>
</table>
</td>
</tr>
Just vertically align the image.
<table>
<tr>
<td valign="middle" bgcolor="#e2f4ff" style="padding:0">
<table width="100%" align="center" border="1" style="border-spacing:0;font-family:sans-serif;color:#333333;">
<tr>
<td valign="middle" style="vertical-align: middle !important;padding:0;text-align:left;padding-bottom: 5px !important;color: #17a0ce;font-weight: bold; Margin:0;font-size:26px; text-align: center;">
THE
<img style="vertical-align: middle !important;" src="http://www.waldenway.com/wp-content/uploads/2015/12/largedog.png" alt="ABC's" />OF SAFE SLEEP FOR DOGS
</td>
</tr>
</table>
</td>
</tr>
</table>
The best solution that works for all email clients is to push them to consider putting that particular image inline with the other text. That can be done by put the text and the image in many <td> of the same single row <tr>.
This will make you able to define the exact height, width and any other attributes you want of each tag.
Check the following:
<table>
<tr>
<td valign="middle" bgcolor="#e2f4ff" style="padding:0">
<table width="100%" align="center" border="1" style="border-spacing:0;font-family:sans-serif;color:#333333;">
<tr>
<td valign="middle">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="middle" style="vertical-align: middle !important;padding:0;text-align:left;padding-bottom: 5px !important;color: #17a0ce;font-weight: bold; Margin:0;font-size:26px; text-align: center;">
THE
</td>
<td valign="middle" style="vertical-align: middle !important;padding:0;">
<img style="vertical-align: middle !important;" src="http://www.waldenway.com/wp-content/uploads/2015/12/largedog.png" alt="ABC's" />
</td>
<td valign="middle" style="vertical-align: middle !important;padding:0;text-align:left;padding-bottom: 5px !important;color: #17a0ce;font-weight: bold; Margin:0;font-size:26px; text-align: center;"> OF SAFE SLEEP FOR DOGS
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
I'm coding an email newsletter that must look correct in all email clients, including Outlook 2007+. One section of the email contains two columns that roughly looks like this:
----------------------------------------
| | |
| | |
| fluid | 340px wide |
| content | ad |
| | |
| | |
----------------------------------------
The ad in the right column should always be 340px. The left column should shrink and grow to fill the remaining space. This is easy to accomplish with a table based layout as long as the screen remains large enough.
However, for smaller screens, such as phones, we need the ad and content to move onto another line, otherwise it forces horizontal scrolling. We originally accomplished this with floated divs, and a min-width and max-width on the left column. But this does not work on Outlook as it both ignores the float and reformats the divs, and the only workaround we've found for Outlook's eccentricities is to convert our divs to tables (which won't work in this case).
Is it possible to accomplish what we're trying to accomplish in Outlook 2007+?
The closest I've come is the below, which is not fluid:
<table class="msoFix" width="270" cellpadding="0" cellspacing="0" align="left">
<tr>
<td width="15"> </td>
<td width="250" align="left" style="padding: 0px; font-family:Arial, Helvetica, sans-serif; color:###textColor#; font-size:14px; line-height:16px; font-weight:normal;">
Content
</td>
<td width="5"> </td>
</tr>
</table>
<table class="msoFix" width="355" cellpadding="0" cellspacing="0" align="right">
<tr>
<td width="5"> </td>
<td width="345" align="right" style="padding: 0px;">
Ad
</td>
<td width="5"> </td>
</tr>
</table>
Not sure if this would work but newer things like phones should be browser compatible whereas outlook isn't so you could use media queries to change you tables into block elements for smaller screens (allowing for stacking) and this should be ignored by outlook so you should still have the table layout. But to make your table fluid, you need to add a width onto every column that is fixed width and then leave the fluid column with no width. I would also merge the 2 above tables:
#media (max-width: 345px) {
.msoFix, .msoFix * {
display:block;
width:100%;
}
.msoFix td.spacer {
display:none;
}
}
<table class="msoFix" width="100%" cellpadding="0" cellspacing="0" align="left">
<tr>
<td width="15" class="spacer"> </td>
<td align="left" style="padding: 0px; font-family:Arial, Helvetica, sans-serif; background:green; font-size:14px; line-height:16px; font-weight:normal;">Content</td>
<td width="5" class="spacer"> </td>
<td width="345" align="right" style="padding: 0px; background:blue;">Ad</td>
<td width="5" class="spacer"> </td>
</tr>
</table>
Example Fiddle
Yes it is possible, you can use media queries for mobile as they can read them...
It would look like this.
#media max-width(380px) {
table[class=left-column],
table[class=right-column] {
width: 100% !important;
}
}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th scope="col"> </th>
<th scope="col"> </th>
<th scope="col"> </th>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3">
<!-- give the tables a class then use a media query for mobiles -->
<!-- I've found that using 2-3% less than 100% width removes possible errors in outlook -->
<table width="32%" cellpadding="0" cellspacing="0" align="left" class="left-column">
<tr>
<td width="15"> </td>
<td width="250" align="left" style="padding: 0px; font-family:Arial, Helvetica, sans-serif; color:###textColor#; font-size:14px; line-height:16px; font-weight:normal;">
Content
</td>
<td width="5"> </td>
</tr>
</table>
<table width="65%" cellpadding="0" cellspacing="0" align="right" class="right-column">
<tr>
<td width="5"> </td>
<td width="345" align="right" style="padding: 0px;">
Ad <!-- set the ad to 100% width -->
</td>
<td width="5"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
css-tricks has a good article on responsive columns in emails. https://css-tricks.com/ideas-behind-responsive-emails/
I'm trying to put together a simple HTML email using old school coding standards and I've hit a brick wall that I didn't foresee. Internet Explorer, even IE 11, renders a simple table differently to every other browser I've tried (Chrome, Firefox, Safari) and I can't figure out why.
In terms of layout, it should look like this (note: colours are for illustration only -- apologies to your eyes!):
But in IE it looks like this:
The HTML is pretty simple:
<table border="0" cellpadding="0" cellspacing="0" width="650" bgcolor="ffffff">
<tr>
<td bgcolor="#ff0000" valign="top" height="250" width='30' rowspan="3">
Height: 250px
</td>
<td background="images/top_2_2a.gif" bgcolor="#00ff00" valign="top" width="455" height="42">
Height: 42px
</td>
<td background="images/top_2_3a.gif" bgcolor="#0000ff" valign="top" width="135" height="116" rowspan="2">
Height: 116px
</td>
<td bgcolor="#ff00ff" valign="top" height="250" width='30' rowspan="3">
Height: 250px
</td>
</tr>
<tr>
<td background="images/top_2_2b.gif" bgcolor="#00ffff" valign="top" width="455" height="208" rowspan="2">
<div>
<div style="font-size:43px; color:#000; font-family: arial; vertical-align: bottom">
Height: 208px
</div>
</div>
</td>
</tr>
<tr>
<td background="images/top_2_3b.gif" bgcolor="#ffff00" valign="top" width="135" height="134">
<div>
<div style="padding-bottom:0px;font-size:13px; color:#000; vertical-align: bottom;font-family: arial">
Height: 134px
</div>
</div>
</td>
</tr>
</table>
JSFiddle: http://jsfiddle.net/mCLDh/
Am I doing something wrong, or is IE still messing with me after all these years?
(Note: For the commenters who are unaware, you cannot use floats or absolute positioning in HTML emails. That's why I'm using code that looks like it came from 1998. It's ugly, but it's more supported by email clients.)
What you are experiencing is the rowspan version of the Outlook issue pointed out here.
Nested tables are the logical choice, however, you can get your code working by adding empty cells on the left to enforce the row heights, making Outlook behave as expected.
<table border="0" cellpadding="0" cellspacing="0" width="650" bgcolor="ffffff">
<tr>
<td bgcolor="#ff0000" valign="top" height="42" width='0'><!-- Empty cell for outlook -->
</td>
<td bgcolor="#ff0000" valign="top" height="250" width='30' rowspan="3">
Height: 250px
</td>
<td background="images/top_2_2a.gif" bgcolor="#00ff00" valign="top" width="455" height="42">
Height: 42px
</td>
<td background="images/top_2_3a.gif" bgcolor="#0000ff" valign="top" width="135" height="116" rowspan="2">
Height: 116px
</td>
<td bgcolor="#ff00ff" valign="top" height="250" width='30' rowspan="3">
Height: 250px
</td>
</tr>
<tr>
<td bgcolor="#ff0000" valign="top" height="74" width='0'><!-- Empty cell for outlook -->
</td>
<td background="images/top_2_2b.gif" bgcolor="#00ffff" valign="top" width="455" height="208" rowspan="2">
<div>
<div style="font-size:43px; color:#000; font-family: arial; vertical-align: bottom">
Height: 208px
</div>
</div>
</td>
</tr>
<tr>
<td bgcolor="#ff0000" valign="top" height="134" width='0'><!-- Empty cell for outlook -->
</td>
<td background="images/top_2_3b.gif" bgcolor="#ffff00" valign="top" width="135" height="134">
<div>
<div style="padding-bottom:0px;font-size:13px; color:#000; vertical-align: bottom;font-family: arial">
Height: 134px
</div>
</div>
</td>
</tr>
</table>
Your best bet is nested tables
http://jsfiddle.net/3L8qL/1/
like so
<table border="0" cellpadding="0" cellspacing="0" width="650" bgcolor="ffffff">
<tr>
<td bgcolor="#ff0000" valign="top" height="250" width='30'>Height: 250px</td>
<td>
<table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td background="images/top_2_2a.gif" bgcolor="#00ff00" valign="top" width="455" height="42">Height: 42px</td>
</tr>
<tr>
<td background="images/top_2_2b.gif" bgcolor="#00ffff" valign="top" width="455" height="208" >
<div>
<div style="font-size:43px; color:#000; font-family: arial; vertical-align: bottom">Height: 208px</div>
</div>
</td>
</tr>
</table>
</td>
<td>
<table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td background="images/top_2_3a.gif" bgcolor="#0000ff" valign="top" width="135" height="116" >Height: 116px</td>
</tr>
<tr>
<td background="images/top_2_3b.gif" bgcolor="#ffff00" valign="top" width="135" height="134">
<div>
<div style="padding-bottom:0px;font-size:13px; color:#000; vertical-align: bottom;font-family: arial">Height: 134px</div>
</div>
</td>
</tr>
</table>
</td>
<td bgcolor="#ff00ff" valign="top" height="250" width='30'>Height: 250px</td>
</tr>
</table>
Edit:
Here's why the browser was confused.
You have created a table with 3 total rows. The sum height of all three rows is 250px.
In the second column, the first row is 42px, and the sum of the bottom two is 208px
In the third column, the first two rows is 116px, and the third row is 134px.
Which means that (table wide) the first row is defined at 42px, the third row is at 134px but the middle row is ambiguous at 166px, 92px, AND -18px at the same time.
Tables are meant to be tabular, but when you break the nature of the table, it's a crap shoot on what you'll get.
Ok, since you stated that it will be used for a html e-mail: do NOT use colspan, rowspan. split the table up in: (not it is NOT pretty but it will save you a metric shit-ton of problems)
<table>
<tr>
<td>
250px
</td>
<td>
<table>
<tr>
<td>
height 42px
</td>
</tr>
<tr>
<td>
height 208px
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>
height 116px
</td>
</tr>
<tr>
<td>
height 134px
</td>
</tr>
</table>
</td>
<td>
250px
</td>
</tr>
</table>
(correct me if this can be done more easy, and yes, the inner tables can be replaced with divs.)
oh, and a shout out to ZURB for coming up with INK: http://zurb.com/ink/ (saved me heaps of trouble)
Interesting, must be minimum size thing, because if you make that value larger, it will render the same as others -- try 200 for example. But, IE doesn't make it smaller since it wants it to be the same height (or larger) than the next column.