Reputation: 907
I am writing some code for sending HTML e-mails. Due to the non-standard nature of e-mail clients, I am restricted to some pretty antediluvian code (no Javascript, no divs, no CSS shortcuts, etc.)
The call-to-action buttons are TDs but so far I haven't been able to make the whole button clickable; just the text in the middle.
The code is something like
<table width="100%" border="0" cellpadding="0" cellspacing="20">
<tr>
<td align="center" valign="middle" width="33%" style="background-color:#6483c1; border:1px solid #44619a; border-radius:2px; padding-top:20px; padding-right:10px; padding-bottom:20px; padding-left:10px;">
<a href="http://littlehotels.co.uk/travelinsurance.php" target="_blank" style="color:#FFFFFF; text-decoration:none;"><font size="3" face="Arial, Helvetica, sans-serif" color="#ffffff"><b>Travel Insurance</b></font></a>
</td>
I have already tried adding display:block
to the td style, but that didn't work.
Am I trying to do the impossible?
Upvotes: 5
Views: 16200
Reputation: 3587
There is a way, it is not precisely what you are asking for, but should give you want you want - even in Outlook! You were on the right track, but the CSS stylings should be on the a tag instead. The best part is that there is a free online tool that can create the code for you.
Go to buttons.cm and it will create the html and VML needed to give you a fully clickable button in HTML/CSS and not just as an image.
Added code output from buttons.cm as reference in case it ever gets taken down:
<table width="100%" border="0" cellpadding="0" cellspacing="20">
<tr>
<td align="center" valign="middle" width="33%"><div><!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://littlehotels.co.uk/travelinsurance.php" style="height:40px;v-text-anchor:middle;width:200px;" arcsize="5%" strokecolor="#44619a" fillcolor="#6483c1">
<w:anchorlock/>
<center style="color:#ffffff;font-family:sans-serif;font-size:13px;font-weight:bold;">Travel Insurance</center>
</v:roundrect>
<![endif]--><a href="http://littlehotels.co.uk/travelinsurance.php"
style="background-color:#6483c1;border:1px solid #44619a;border-radius:2px;color:#ffffff;display:inline-block;font-family:sans-serif;font-size:16px;font-weight:bold;line-height:40px;text-align:center;text-decoration:none;width:200px;-webkit-text-size-adjust:none;mso-hide:all;">Travel Insurance</a></div>
</td>
</tr>
</table>
Upvotes: 0
Reputation: 206258
You cannot make a <td>
clickable without JS
Enlarge the inner <a>
size instead - to cover the needed area,
setting it's display
to block
might help.
Upvotes: 1
Reputation: 207919
Make the anchor a block level element and move the padding from the table cell to the anchor:
<table width="100%" border="0" cellpadding="0" cellspacing="20">
<tr>
<td align="center" valign="middle" width="33%" style="background-color:#6483c1; border:1px solid #44619a; border-radius:2px;">
<a href="http://littlehotels.co.uk/travelinsurance.php" target="_blank" style="padding:20px 10px;display:block;color:#FFFFFF; text-decoration:none;"><font size="3" face="Arial, Helvetica, sans-serif" color="#ffffff"><b>Travel Insurance</b></font></a>
</td>
</tr>
</table>
Upvotes: 9