mso- CSS, for fully-clickable buttons in Outlook for Windows.
Link
This is inspired by @M_J_Robbins’ link button - see the original on goodemailcode.com
<a> tag, but with some nifty workarounds for Outlook’s lack of support for padding on inline elements:
- left/right padding is faked with
<i>elements that usemso-font-widthwith a to grow in width; these elements are wrapped in conditional comments, so they only show in Outlook and Windows 10 Mail - the text label is wrapped in a
<span>andmso-text-raiseadjusts its vertical position, allowing us to control the top padding - the first
<i>also adds bottom padding
Line breaks and spaces between tags in the example above might render the button larger (although barely noticeable). If you want your button to be absolutely pixel perfect, just remove them.
VML
Another approach to buttons in HTML email is coding them with VML, Microsoft’s obsolete and deprecated Vector Markup Language. buttons.cm, a tool by Campaign Monitor, makes it easy to generate a VML button. However, you should keep in mind that VML buttons:- have a larger code footprint
- must have a fixed width and height
- require that you add the URL in two places
- are converted to an image, which can degrade accessibility for screen reader users
- cannot be nested inside other VML elements (for example, background images for Outlook require VML, so you can’t place a VML button on top of a background image for Outlook)
Rounded corners in Outlook
Probably the only reason you’d want to use a VML button is because it’s the only way to achieve rounded button corners in Outlook for Windows. Here is a simplified VML button with rounded corners, styled with Tailwind CSS:vml-rounded-button.html
Table-based
A simple table structure, with background color set on the cell. For modern email clients, we use CSS padding on the<a> to make the entire button clickable. In Outlook and Windows 10 Mail, because CSS padding isn’t supported on anchor tags, the MSO mso-padding-alt CSS property can be used on the table cell in order to preserve the visual aspect.
This means that in Outlook/Windows 10 Mail only the text itself will be clickable.
Table-based buttons are easier to code and maintain than VML buttons, the main trade-off being accessibility: the click area in Outlook is not ideal.
Filled
The most common type of button. For an extra touch, let’s add rounded corners and a hover effect:Outlook doesn’t support
border-radius, it will render square corners.