Styling button with border & offset using email HTML - html

I have a design of an email template, and I am tinkering about the best way to tackle the styling of the following element in HTML/CSS. Note a few things:
Since it's for an HTML email, mainly tables will be used.
Using negative margins will probably not be compatible with different mail clients.
Note the white border around the button
Would you recommend using a background image for this entire block? Or is there an elegant way that will look like this and works across clients.
Here's my set-up: http://jsfiddle.net/ZHkdV/

Here you go - only need a 30x30 image for the top corner:
<table width="300" border="0" cellpadding="0" cellspacing="0" bgcolor="#F1F1F1">
<tr>
<td width="30" height="30">
<img style="margin: 0; border: 0; padding: 0; display: block;" src="" width="30" height="30" alt="">
</td>
<td width="240" height="30">
</td>
<td width="30" height="30">
</td>
</tr>
<tr>
<td width="30" height="160">
</td>
<td width="240" height="160" valign="top">
<font style="font-family: Helvetica, Arial, sans-serif; font-size: 14px; color: #757575;">
<br>
some text here
</font>
</td>
<td width="30" height="160">
</td>
</tr>
<tr>
<td width="300" height="40" colspan="3" bgcolor="#FFFFFF"><!-- undeclared light gray as Outlook can add spaces at bottom of this td on forwarding (hides unwanted line) -->
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50" height="20" bgcolor="#F1F1F1">
</td>
<a href="" style="color: #757575; font-weight: bold; text-decoration: none;"><!-- css button, you can lose this and put a href'd image in the cell if you prefer. -->
<td width="200" height="40" bgcolor="#CBBCDC" rowspan="2" valign="middle" align="center">
<font style="font-family: Helvetica, Arial, sans-serif; font-size: 14px; color: #757575;">
BUTTON
</font>
</td>
</a>
<td width="50" height="20" bgcolor="#F1F1F1">
</td>
</tr>
<tr>
<td width="50" height="20" bgcolor="FFFFFF">
</td>
<td width="50" height="20" bgcolor="FFFFFF">
</td>
</tr>
</table>
</td>
</tr>
</table>
This should hold up in all clients...

For e-mail templates, you don't have to worry about validation, so you can use pretty 'hacky' html. One way round client compatibility is to have every row be a table in and of itself, set inside one main 'wrapper' table.
Then you can set as many divisions as you want in each, remembering to reset the borders on each table, row and cell.
Each cell gets it's own image or slice of an image. For the last row you could simply have one image in an anchor tag. Also remember to keep all styling on elements inline.
The html email Boilerplate is pretty much bulletproof.
http://htmlemailboilerplate.com/
<table> <!- Wrapper ->
<tr>
<td>
<table>
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr>
</table>

Background images aren't very compatible either:
http://www.campaignmonitor.com/css/
I would just slice the last row into 3 separate images (left, button, right).
If you would rather have one image for the whole row, you can also use an image map to just make the button part a link.

Related

Having problems with website coding, centering a picture

I'm having problems with the following code.
<tbody>
<tr align="center">
<td>
<p align="right"><font face="Arial, Helvetica, sans-serif"><strong>Processoren</strong>
<img src="images/IntelPentium4.jpg" align="middle" height="37" width="50"> </font></p>
</td>
<td>
<p align="right"><font face="Arial, Helvetica, sans-serif"><strong>Moederborden
</strong> <img src="images/MB.jpg" align="middle" height="47" width="47"> </font></p>
</td>
</tr>
<tr align="center">
<td height="54" width="50%">
<p align="right"><strong><font face="Arial, Helvetica, sans-serif">Geheugen <img src="images/geh.gif" align="middle" height="47" width="50"></font></strong></p>
</td>
<td height="54" width="50%">
<p align="right"><strong><font face="Arial, Helvetica, sans-serif">Grafische kaarten <img src="images/56326.jpg" align="middle" height="50" width="50"></font></strong></p></td>
</tr>
<br><br><br>
</tbody><tbody>
<tr align="right">
<td align="left"> <img src="images/gamepc1.png" width="140" > </td>
<td align="right"> <img src="images/gamepc2.jpg" width="120"> </td></tr>
</tbody><tr>
<td></td>
<td class="test11"><img src="images/annie2.png" width="140">
</td></tr>
<tbody>
<tr align="right">
<td align="left"> <img src="images/gamepc3.png" width="120"> </td>
<td align="right"> <img src="images/gamepc4.png" width="100"> </td>
</tr>
</tbody></table>
enter image description here
Basicly, I can't figure out how to center the anime picture. Please dont ask me why there is random anyme on this webpage, but the owner of the store wanted me to do that. I've tried so many options to center the picture, they just work. Could someone try to take a look at it and help me out?
I tried centering it with css rules, also tried margin-left shit but I cant figure out why its not reaction on such code.
I've never worked with and before. I'm a first year student who had to make some websites for school that worked out pretty good. My friend asked me if I could fix some stuff for his work's owner's website. This website is designed like 10years ago. I already asked him if I couldn't just make a new one, but he insisted that I need to use this one.
Could someone help me out? Thanks!
Inside your tbody with the image of the anime you are using two <td>.
You can delete the first <td></td> and use colspan="2" for the other td, so you will only need one td. This td will take the full width. Now you can easily center the image.
<td colspan="2" class="test11" style="text-align:center;">
<img src="images/annie2.png" width="140">
</td>
Result look like this (be aware, I have not included the sources of the images).

How to align a text link next to an image link in a table row with inline styles only?

I'm having an issue aligning text and an image link next to each other in a table row. The image keeps drifting up and down. I've tried various align middle and display block styles with no luck. I am limited to only having CSS inline and trying to display properly across different devices and desktop email clients. The posted code is a nested table that I can not get the elements to align with each other. Viewing the code in the browser, for the most part, displays correctly. But once the code is in Outlook and other programs the image drifts within the row.
image example
<table cellspacing="0" cellpadding="0">
<td height="100%" align="left">
555-555-5555 |
</td>
<td height="100%" align="left">
stackoverflow.com |
</td>
<td height="100%" align="left" font-size="13px" style="font-size: 13px; line-height:100%;">
<img src="https://i.ibb.co/hf2gbC1/in.png" style="margin-left: 4px; margin-right: 2px" alt="Stack Overflow LinkedIn" width="11" height="11">
</td>
</table>
This is very simple and when tested with Litmus it has consistent results across all email clients. I set the font size, line-height and image size to 13px. Since they were all equal, it made it easier to align. I didn't put an align on the table because it should default to middle-align. On the image I placed vertical-align: -2px; Outlook has buggy support when it comes to using values like middle, but not with number values. in the style sheet and added display: inline-block;. I placed everything in one <td>.
With Gmail, Apple, IOS, Android and other email clients, everything remains consistent. With Outlook, it shifts about a pixel.
I also added text-decoration: none; to the hrefs to clean up the look a bit.
<table role="presentation" cellspacing="0" cellpadding="0" border="0" style="margin: 0;">
<tr>
<td style="font-family: sans-serif; font-size: 13px; line-height: 13px; text-decoration: none;">
555-555-5555 |
stackoverflow.com |
<img src="https://i.ibb.co/hf2gbC1/in.png" style="vertical-align: -2px;" alt="United States Appraisals LinkedIn" width="13" height="13">
</td>
</tr>
</table>
Good luck.
I would use valign="bottom" for all tds, and in addition add some padding-bottom to the img tag to correct the slight vertical offset between text and image (actually only 1px in this particular example):
<table cellspacing="0" cellpadding="0">
<td height="100%" align="left" valign="bottom">
555-555-5555 |
</td>
<td height="100%" align="left" valign="bottom">
stackoverflow.com |
</td>
<td height="100%" align="left" font-size="13px" style="font-size: 13px; line-height:100%;" valign="bottom">
<img src="https://i.ibb.co/hf2gbC1/in.png" style="margin-left: 4px; margin-right: 2px; padding-bottom: 1px;" alt="United States Appraisals LinkedIn" width="11" height="11">
</td>
</table>
writing html for email is like a trip back to the 90ies!
if you wrap all your <td> inside a tabelrow <tr> and set it's valign to bottom,
just run the code snippet:
<table cellspacing="0" cellpadding="0">
<tr height="20px" valign="bottom" bgcolor="#FFFFCC" >
<td height="100%" align="left">
555-555-5555 |
</td>
<td height="100%" align="left">
stackoverflow.com |
</td>
<td height="100%" align="left" font-size="13px" style="font-size: 13px; line-height:100%;">
<img src="https://i.ibb.co/hf2gbC1/in.png" style="margin-left: 4px; margin-right: 2px" alt="United States Appraisals LinkedIn" width="11" height="11">
</td>
</tr>
</table>

Placing Anchored Images on top of table background for email template

I have the following code for a background Image on a table, which has some image links on top of it as well as a logo. I am using a mailchimp account and I would like to make the background editable. it is not possible to make background images editable.
So I am wondering about alternative solutions to have the social links and logo on top of a image while still allowing a image underneath to be editable, so background image without a background property in a table, that is compatible in most email clients, that allows for editing in Mailchimp.
<table mc:edit="backgroundImage" class="backgroundHeader" background="http://104.131.7.150/public/vancouverSunrise.jpg" border="0" cellpadding="0" height="400" cellspacing="0" width="100%">
<tr valign="top">
<td>
<div align="right" style="padding: 40px 15px 0px 15px;">
<table border="0" cellpadding="0" cellspacing="0" width="30">
<!-- LOGO/PREHEADER TEXT -->
<tr align="right">
<td><a mc:edit="linkedin" href="*|CUSTOM_URL|*"><img src="linkedin.png" width="46.6" height="44" /></a></td>
<td><a mc:edit="facebook" href="*|CUSTOM_URL|*"><img src="facebook.png" width="46.6" height="44" /></a></td>
<td><a mc:edit="twitter" href="*|CUSTOM_URL|*"><img src="twitter.png" width="46.6" height="44" /></a></td>
</tr>
</table>
</div>
</td>
</tr>
<tr valign="top">
<td>
<div align="center" style="padding: 10px 15px 0px 15px;">
<table border="0" cellpadding="0" cellspacing="0" width="30" class="wrapper">
<!-- LOGO/PREHEADER TEXT -->
<tr align="center">
<td><img src="image.png" width="244" height="126.6" /></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
You can't use z-index either so hacking an img on top of another is impossible.
You need to have a set up based around the code from http://backgrounds.cm/ and have your mc:edit attributes get to the filename in both the background attribute of the TD (not the table, table backgrounds don't work in most clients) and the VML script from the generated code. You also need to update the height and width attributes on the TD and VML.

HTML Email in iOS

I am getting a line across a table I made in an html email. It is in the orange area. I'm not really sure what is causing is. There is no images in there. Here is my code for that table.
<table cellpadding="0" cellspacing="0" border="0" width="625" align="center" bgcolor="#FFFFFF">
<tr>
<td height="23" bgcolor="#f08122" colspan="3"> </td>
</tr>
<tr>
<td width="23" bgcolor="#f08122"></td>
<td bgcolor="#f08122" valign="middle" style="font-family:Helvetica, Arial, sans-serif; color:#FFFFFF;" align="center"><span style="font-size:30px; line-height:36px; font-weight:bold;"><strong>Improve outcomes and empower patients with health logs</strong></span><br /><br />
<span style="font-size:27px;">Order now and get <strong>10% more FREE!*</strong></span></td>
<td width="23" bgcolor="#f08122"></td>
</tr>
<tr>
<td height="23" bgcolor="#f08122" colspan="3"> </td>
</tr>
<tr>
<td height="5" colspan="3"></td>
</tr>
</table>
Here is the link to the actual email also if you wanted an active view: https://tagwebstore.com/email/tag-email-logbooks.html
Here is a screenshot of the html email from my iPhone.
The lines appear to be above and below the white text. Any ideas? Thanks in advance.
The borders appear when a background color or image is applied to individual table cells.
you can try:
Removing background colors or images from individual table rows and
cells, and/or;
Nesting the problem table in a new table, featuring a background color that matches that of the inner table.
source
Also, setting style="display: block;" on the img element consistently helps all images position exactly, in tandem with the above suggestions.

HTML Email not displaying correctly in Outlook 2007

After a lot of time I put into researching. I still can't find an answer.
I have a HTML that is showing the wrong width in my tables. Here is a link to the html email: https://tagwebstore.com/email/tag-email-10percentmore.html and here is a screenshot of how it looks in Outlook 2007:
The main problem is the bottom area. The link of the html email displays it correctly. I have no idea what else to do from here. Here is my code for the bottom part I am having trouble with:
<table cellpadding="0" cellspacing="0" border="0" width="625" align="center" bgcolor="#FFFFFF">
<tr>
<td height="23" colspan="3" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td width="25"> </td>
<td><table cellpadding="0" cellspacing="0" border="0">
<tr>
<td><img src="https://www.tagwebstore.com/email/testimonial-top.png" width="573" height="36" style="display:block;" /></td>
</tr>
<tr>
<td bgcolor="#f0d7c1" width="573"><table cellpadding="0" cellspacing="0" border="0" width="573">
<tr>
<td width="28"></td>
<td style="font-size:11px; line-height:18px; color:#000000; font-style:italic; font-family:Helvetica, Arial, sans-serif;" width="517"><table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="font-size:11px; line-height:18px; color:#000000; font-style:italic; font-family:Helvetica, Arial, sans-serif;">We’ve been using TAG for a while and we love TAG – we love the products. When we bring the products to Oklahoma City, nobody else has the products. It’s a big plus here for our market area. I think it would be a great thing for people to get online and see what TAG can do for them.</td>
</tr>
<tr align="right">
<td height="40" valign="bottom" style="font-size:11px; line-height:18px; color:#000000; font-style:normal; font-weight:bold; font-family:Helvetica, Arial, sans-serif;">Sirron Brown, Marketing Director<br />
Excell Home Care and Hospice, Oklahoma</td>
</tr>
</table></td>
<td width="28"></td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="https://www.tagwebstore.com/email/testimonial-bottom.png" width="573" height="57" /></td>
</tr>
</table></td>
<td width="25"> </td>
</tr>
</table>
<!--Testimonial End-->
<!--Footer-->
<table cellpadding="0" cellspacing="0" border="0" width="625" align="center" bgcolor="#FFFFFF">
<tr>
<td colspan="3" height="20"> </td>
</tr>
<tr>
<td width="25"> </td>
<td width="575"><table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="middle" width="295" style="font-family:Helvetica, Arial, sans-serif; font-size:12px;">info#tagwebstore.com | 866.232.6477</td>
<td width="178" style="font-family:Helvetica, Arial, sans-serif; font-size:12px;" valign="middle" align="right">Follow us on Twitter & YouTube</td>
<td valign="middle" width="102"><img src="https://www.tagwebstore.com/email/twitter.png" width="49" height="17" border="0" /><img src="https://www.tagwebstore.com/email/youtube.png" width="53" height="21" border="0" /></td>
</tr>
</table></td>
<td width="25"> </td>
</tr>
<tr>
<td colspan="3" height="20"> </td>
</tr>
</table>
<!--Footer End-->
The width of the containing table is suppose to be 625px. Any help is appreciated.
oh the joy of html emails
There are many rules you have to obey when dealing with HTML-based email, especially when you have exacting clients and pixel-perfect designs, and I am quite glad that I haven't had to work on such a project for at least two years now... The main reason for my utter dislike of the practice is primarily down to two email-clients. The first and all time worst being Lotus Notes 6.5.4 (to be fair it's over 10 years old now.. but still!), and the all time second worst(s), they're not even the best at being bad, Outlook 2007 and 2010!
Whoever thought it would be a good idea to use the Microsoft Word WYSIWYG HTML Engine to render HTML Emails in Outlook 2007 and 2010, must have been mad, lazy, lost or ever-so-slightly confused (delete as appropriate). It causes no end of rendering problems for developers, usually with random and inexplicable sizing calculations or padding problems.
Taken from my blog http://blog.pebbl.co.uk/2011/06/collapsible-html-email-and-outlook.html
Simply put, I do not envy you :)
I found the best way to help me out with my email troubles was to follow the following rules:
Never use colspans or rowspans.
Always set correct dimensions for your tables and cells.
Use spacer gifs rather than &nbps;.
Always specify correct image sizes and never scale images up or down.
Always add style="display:block;" to images.
Avoid using divs.
If you wish to colour links, put the styling on a span as a child inside the a tag.
Don't use italics.
Don't use BRs for layout, always use tables.
Use BRs in Text, not Ps (to avoid stange margin problems and paragraphing being completely ignored).
Because the sheer number of emails I used to get through ended up being ridiculous, I developed a script to help me with the work of checking dimensions and other possible pitfalls. If you're interested in using it you can find it here:
http://pastie.org/6250834
The script can be added as a usual script tag or enabled using GreaseMonkey or something similar (it was designed to work with Firefox but I see no reason why it shouldn't work elsewhere). Due to the way I used to build my emails, it will only enable itself if either the following conditions are met:
There is an outer wrapping table that has width="100%" set, used to centre the actual email content.
or... there is an outer element (a table or div) that has the id="base".
I've passed your HTML through it and the image below is the resulting output, it makes more sense when you have the actual page because you can hover over each bordered item and it will give you a rough idea of what the problem is (either that or you can just inspect the element directly with Firebug or similar).
So from inspecting the above it seems you have a few problems that need to be fixed, I'd say the most important ones are to get rid of rowspans and colspans (these always cause problems in Outlook) and to make sure all your dimensions tally correctly. Once you've fixed these issues you might see a considerable improvement, but then again you might not, there are no certainties in the hazardous life of HTML email building...
Hope it helps.
Try this for your top table:
<table cellpadding="0" cellspacing="0" border="0" width="625" align="center" bgcolor="#FFFFFF">
<tr>
<td height="23" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td width="25"> </td>
<td width="575">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<img src="https://www.tagwebstore.com/email/testimonial-top.png" width="575" height="36" style="display:block;" />
</td>
</tr>
<tr>
<td bgcolor="#f0d7c1" width="575">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="28">
</td>
<td width="519" style="font-size:11px; line-height:18px; color:#000000; font-style:italic; font-family:Helvetica, Arial, sans-serif;">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="font-size:11px; line-height:18px; color:#000000; font-style:italic; font-family:Helvetica, Arial, sans-serif;">We’ve been using TAG for a while and we love TAG – we love the products. When we bring the products to Oklahoma City, nobody else has the products. It’s a big plus here for our market area. I think it would be a great thing for people to get online and see what TAG can do for them.
</td>
</tr>
<tr align="right">
<td valign="bottom" style="font-size:11px; line-height:18px; color:#000000; font-style:normal; font-weight:bold; font-family:Helvetica, Arial, sans-serif;">Sirron Brown, Marketing Director<br />
Excell Home Care and Hospice, Oklahoma</td>
</tr>
</table>
</td>
<td width="28">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<img src="https://www.tagwebstore.com/email/testimonial-bottom.png" width="575" height="57" style="display:block;" />
</td>
</tr>
</table>
</td>
<td width="25"> </td>
</tr>
</table>
and this for your bottom:
<table cellpadding="0" cellspacing="0" border="0" width="625" align="center" bgcolor="#FFFFFF">
<tr>
<td colspan="3" height="20"> </td>
</tr>
<tr>
<td width="25"> </td>
<td width="575">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="middle" width="280" style="font-family:Helvetica, Arial, sans-serif; font-size:12px;">
info#tagwebstore.com | 866.232.6477
</td>
<td width="193" style="font-family:Helvetica, Arial, sans-serif; font-size:12px;" valign="middle" align="right">
Follow us on Twitter & YouTube
</td>
<td valign="middle" width="49">
<img src="https://www.tagwebstore.com/email/twitter.png" width="49" height="17" border="0" style="display:block;" />
</td>
<td valign="middle" width="53">
<img src="https://www.tagwebstore.com/email/youtube.png" width="53" height="21" border="0" style="display:block;" />
</td>
</tr>
</table>
</td>
<td width="25"> </td>
</tr>
<tr>
<td colspan="3" height="20"> </td>
</tr>
</table>
Overall it was coded really well, just changed a few small things, not saying each was a must have, but IF it works you can reverse engineer the changes to find out what busted it. I haven't tested it, so hopefully this works...