Sub topic 8
Building buttons that survive every client
This chapter assumes you know basic HTML and CSS, the box model, and how the earlier chapters build a table-based layout with inline CSS. It covers how to build a call-to-action button that stays visible, colored, and easy to tap in clients with limited CSS or image support.
Why a normal button fails in email
On the web you would write a <button> or style an <a> with a background, padding, and border radius. In email, each of those choices can break:
- Form elements such as
<button>are stripped or inert in many clients, so a click does nothing. - Image buttons disappear when a client blocks images. If the button text lives inside the image, the call to action disappears with it.
- Desktop Outlook renders with the Word engine. It often ignores
paddingon<a>elements, so the clickable area shrinks to the text. - Some clients drop
backgroundon inline elements or rewrite your styles.
A bulletproof button is built from live HTML text and a colored table cell. It does not depend on an image or on any one CSS feature. If a style is dropped, the button degrades but remains readable and clickable.
The basic pattern
The pattern puts the background color on a table cell and the padding on a link inside it.
<table role="presentation" cellpadding="0" cellspacing="0" border="0">
<tr>
<td bgcolor="#0b5fff" style="border-radius:6px;">
<a href="https://example.com/order" style="display:inline-block;padding:14px 28px;font-family:Arial,Helvetica,sans-serif;font-size:16px;line-height:20px;font-weight:bold;color:#ffffff;text-decoration:none;">View your order</a>
</td>
</tr>
</table>Each part has a job:
| Part | Purpose |
|---|---|
| `role="presentation"` | Tells assistive technology this table is layout, not data. |
| `bgcolor="#0b5fff"` | An HTML attribute that sets the background color. It works even when CSS support is poor. |
| `border-radius:6px` | Rounds the corners. Clients that ignore it show a square button, which is still usable. |
| `display:inline-block` | Lets the link accept padding, so the whole padded area is clickable in most clients. |
| `padding:14px 28px` | Makes the tap target large. |
| `text-decoration:none` | Removes the default underline. |
| `color:#ffffff` | Sets the text color on the link itself, because some clients override the inherited color with their default link color. |
The bgcolor attribute and the background-color style serve the same purpose. Using both is a common safety measure:
<td bgcolor="#0b5fff" style="background-color:#0b5fff;border-radius:6px;">Keep the two values identical. If they differ, different clients will show different colors.
Why the color goes on the cell, not the link
If the link carries the background and the client ignores padding on <a>, you get a thin colored strip around the text. If the cell carries the background, the cell always shows the full color block. The worst case is that the clickable area is only the text inside a colored box. That is a usability problem, but the button still looks correct.
Making the whole button clickable in Outlook
Desktop Outlook is the client where the padded link most often fails. You have three options, in increasing order of effort:
- Accept a smaller clickable area. The button looks right, but only the text is clickable.
- Put the padding on the cell instead of the link, and make the link fill the cell. The padding is then part of the table, which Outlook respects, but the clickable area stays text-only.
- Use a VML
roundrectinside a conditional comment so Outlook draws and links its own button.
The third option is the most reliable for Outlook. It hides the HTML version from Outlook and shows a VML shape instead:
<!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="https://example.com/order" style="height:48px;v-text-anchor:middle;width:200px;" arcsize="12%" stroke="f" fillcolor="#0b5fff">
<w:anchorlock/>
<center style="color:#ffffff;font-family:Arial,Helvetica,sans-serif;font-size:16px;font-weight:bold;">View your order</center>
</v:roundrect>
<![endif]-->
<!--[if !mso]><!-- -->
<table role="presentation" cellpadding="0" cellspacing="0" border="0">
<tr>
<td bgcolor="#0b5fff" style="border-radius:6px;">
<a href="https://example.com/order" style="display:inline-block;padding:14px 28px;font-family:Arial,Helvetica,sans-serif;font-size:16px;line-height:20px;font-weight:bold;color:#ffffff;text-decoration:none;">View your order</a>
</td>
</tr>
</table>
<!--<![endif]-->The first block is read only by Outlook. The second is read by every other client, because <!--[if !mso]><!-- --> and <!--<![endif]--> hide it from Outlook. The cost is that the VML button has a fixed width and height. If you change the label, you must change those numbers as well. The previous chapter's conditional-comment technique for layout uses the same syntax.
How a button degrades
In every branch the label is live text, the color is present, and the link works. That is the property you are designing for.
Tap targets and text on phones
A button that looks fine on a desktop can be hard to hit with a thumb. Follow these guidelines:
- Aim for a tap target at least 44 by 44 pixels. Apple's Human Interface Guidelines recommend 44 points, and Google's Material guidance recommends 48 dp.
- With
font-size:16px,line-height:20px, andpadding:14px, the height is 20 + 14 + 14 = 48 pixels. - Leave space around the button, at least 8 pixels, so neighboring links are not hit by accident.
- Use a label of at least 16px. Clients such as iOS Mail may enlarge text below about 13px unpredictably.
- Write a specific label. "View your order" tells the reader more than "Click here".
Full-width buttons on phones
On a narrow screen, a full-width button is easier to tap. You can make the button fluid with a width of 100% in the table, then let the link fill the cell:
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="center">
<table role="presentation" cellpadding="0" cellspacing="0" border="0" class="full">
<tr>
<td bgcolor="#0b5fff" align="center" style="border-radius:6px;">
<a href="https://example.com/order" style="display:block;padding:14px 28px;font-family:Arial,Helvetica,sans-serif;font-size:16px;line-height:20px;font-weight:bold;color:#ffffff;text-decoration:none;">View your order</a>
</td>
</tr>
</table>
</td>
</tr>
</table>Add a media query in the <style> block of the head to widen the inner table on small screens:
<style>
@media screen and (max-width: 600px) {
.full { width: 100% !important; }
}
</style>Clients that ignore the style block simply keep the compact button. It remains usable, so the full-width version is an enhancement, not a requirement.
Common errors
- Image-only buttons. The label vanishes when images are blocked. If you must use an image, give it descriptive
alttext and abgcolorfallback on the surrounding cell. - Relying on
<button>. Form controls are not supported in most clients. Use a link. - Color only on the link. The background is lost in clients that strip padding or inline backgrounds.
- Forgetting link color. Without an explicit
coloron the<a>, some clients paint the text in their default blue, which can be unreadable on a dark button. - Low contrast. White text on a pale blue cell can fail contrast requirements. WCAG asks for at least 4.5:1 for normal text. White (#ffffff) on #0b5fff meets that ratio.
- Dark mode inversion. Some clients invert or adjust colors automatically. Test that the button still has visible contrast, and consider a 1px border in a mid-tone color so the shape survives a background swap.
- Mismatched VML dimensions. A VML shape too small for its label clips the text in Outlook.
Accessibility notes
A bulletproof button is a link, so screen readers announce it as a link and read its text. Keep the label meaningful on its own, because screen reader users often navigate by listing links. The role="presentation" on the wrapper tables prevents the layout from being read as a data table. Do not add role="button" to a link that navigates to a URL, since the behavior would not match.
Checking your work
Before sending, verify each of these:
- With images turned off, the button still shows its color and label.
- In a narrow viewport, the button is at least 44 pixels tall and has space around it.
- In desktop Outlook, the button shows its color and the label is clickable.
- In dark mode, the label stays readable against the button.
- The link
hrefis correct and useshttps.
Exercise
A teammate builds a button with <a style="display:inline-block;background-color:#0b5fff;padding:14px 28px;color:#ffffff;">, with no table around it. In desktop Outlook the button appears as a thin colored strip behind the text. Explain why this happens and how to change the markup so the full colored block appears in every client.
Show answer
Desktop Outlook uses the Word rendering engine, which often ignores padding on <a> elements. The padding is lost, so the background color is painted only behind the text, which looks like a thin strip. To fix it, wrap the link in a table with one cell, put bgcolor (and background-color) on the cell, and keep the padding and text styling on the link inside it. The cell then paints the full color block even if the link's padding is ignored. For a fully clickable area in Outlook, add a VML roundrect inside a <!--[if mso]> conditional comment and hide the HTML version from Outlook with <!--[if !mso]><!-- -->.
Exercise
A button uses font-size:16px, line-height:20px, and padding:12px 24px on the link. Does its height meet the 44-pixel tap target guideline? What single change brings it to 48 pixels?
Show answer
The height is 20 + 12 + 12 = 44 pixels, so it meets the 44-pixel guideline exactly. Changing the vertical padding to 14px gives 20 + 14 + 14 = 48 pixels, which matches the 48 dp recommendation from Material guidance.