M-J-Robbins / get-off-the-table

Experimenting with building HTML emails without <tables>
MIT License
55 stars 13 forks source link

New CTA proposal #8

Open M-J-Robbins opened 4 years ago

M-J-Robbins commented 4 years ago

I've never been happy with the VML solution for "buttons" (links) in email. Lots of code, doubling the href, can't be nested inside VML background. I've been using the mso-border-alt method but I'm not happy with those either.

So I'm working on a new version...

Code

<a href="https://github.com/M-J-Robbins/get-off-the-table" style="text-decoration:none;background:green;color:white;text-transform:uppercase;border-radius:10px;border:2px solid black;display:inline-block;font-size:50px;line-height: 50px;letter-spacing: 50px;">&nbsp;<span style="letter-spacing:0;font-size:16px;vertical-align: middle;mso-text-raise:10px;">Click it</span>&nbsp;</a>

I'll break the styles down a bit so it makes sense.

text-decoration:none;background:green;color:white;text-transform:uppercase;border-radius:10px;border:2px solid black; This part if just standard styling, nothing exciting here

display:inline-block; This helps vertical alignment in HTML email clients

font-size:50px;line-height: 1em; This defines the height in both HTML email clients and MSO, be aware this can cause issues if the text drops to 2 lines.

letter-spacing: 50px; This helps define the left/right padding. We also need a &nbsp; either side of our text to take this space.

<span style="letter-spacing:0;font-size:16px;vertical-align: middle;mso-text-raise:10px;">Click it</span> To avoid our text looking very spaced out we need to wrap it in a span and reset the letter spacing and font-size to what we're after. Also adding vertical-align for HTML email clients and mso-text-raise for MSO.

Pros

Cons

Issues

Ideas

It's less hacky and preferable to style the "button" (link) normally for HTML email client then add MSO specific code. We can use mso-ansi-font-size instead of font-size and mso-font-width instead of letter-spacing although that's a % and harder to get an exact size.