-
Notifications
You must be signed in to change notification settings - Fork 6
Spacers
Vertical spacing in HTML emails can be tricky, because of inconsistent support for margin
, padding
, and <br>
tags.
Here's how to create simple yet reliable spacers for your emails, using basic HTML and Tailwind CSS.
This is the simplest kind of spacer you can use in an HTML email.
Being a <div>
, it can be used anywhere such an element is allowed.
In our case: before/after a <table>
, inside <td>
or <th>
, or inside other <div>
elements.
<div class="leading-64 sm-h-32">‌</div>
Here's the idea:
-
leading-64
addsline-height: 64px;
- this is the default height, for desktop clients -
sm-h-32
setsheight: 32px;
for thesm
breakpoint - this is the responsive height - We use a
‌
to add something inside, so it can take up height reliably in all email clients
In case the sm-h-{$size}
classes you have defined in your (custom?) Tailwind CSS config are not enough, you can double up by using padding instead:
<div class="leading-64 sm-h-0 sm-py-64">‌</div>
sm-h-0
will reset the height to zero on the sm
breakpoint, and sm-py-64
will add 128px of total padding,
Use this one directly inside a <table>
:
<tr>
<td class="h-64 sm-h-32"></td>
</tr>
By default, Maizzle will transform the inline CSS height: 64px;
to a height="64"
attribute, for consistent email client support.
A simple table with an empty cell that has a height set. Use it anywhere you can't use a Div or Row spacer.
<table class="w-full" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td class="h-64 sm-h-32"></td>
</tr>
</table>
Accessibility
Unless actually displaying tabular data in an email, always add role="presentation"
to your tables.