Vertical alignment not working as expected in HTML

Viewed 157

I'm creating an HTML email signature and for some reason I'm having an issue with aligning an image and some text in the middle vertically. I am looking at my signature by opening the HTML in Chrome/Gmail which both act the same and then separately in Outlook to check for compatibility issues. The vertical alignment doesn't work in either but do output slightly differently.

I'd like a solution to vertical align the image and text together in the middle vertically for both Chrome/Gmail and Outlook.

I've tried lots of different vertical align methods such as using line-height, vertical-align, height and display properties on various elements but they don't make any difference.

Below is my code:

<table role="presentation" width="600" cellpadding="0" cellspacing="0" border="0" style="margin: 20px 0;width: 600px; border-collapse: collapse;">
    <tr>
        <td cellspacing="0" cellpadding="0" border="0" width="180" height="22" style="font-family: Urbanist, Arial, sans-serif; text-align: left; font-size:16px; font-weight: 400; color: #000; padding: 0 0 0 20px;">
            <p style="margin: 0;"><img src="/assets/signature/phone.png" width="22" height="22" style="margin: 0 5px 0 0; width: 22px; height: 22px;" /> XXXXX XXXXXX</p>
        </td>
        <td cellspacing="0" cellpadding="0" border="0" width="240" height="22" style="font-family: Urbanist, Arial, sans-serif; text-align: center; font-size:16px; font-weight: 400; color: #000;">
            <p style="margin: 0;"><span style="text-decoration: none!important; color: #000!important;"><img src="/assets/signature/email.png" width="22" height="22" style="margin: 0 5px 0 0; width: 22px; height: 22px;" /> email@email.co.uk</span></p>
        </td>
        <td cellspacing="0" cellpadding="0" border="0" width="180" height="22" style="font-family: Urbanist, Arial, sans-serif; text-align: right; font-size:16px; font-weight: 400; color: #000; padding: 0 20px 0 0;">
            <p style="margin: 0;"><img src="/assets/signature/web.png" width="22" height="22" style="margin: 0 5px 0 0; width: 22px; height: 22px;" /> www.domain.com</p>
        </td>
    </tr>
</table>

This is my output in Chrome/Gmail: 1

This is my output in Outlook: 2

1 Answers

What about:

table tr {
  display: flex;
  align-items: center;
}

?

Related