Sub topic 2
Fluid and Hybrid Layouts That Scale to the Screen
Assume you know basic HTML and CSS, the box model, media queries, and how email clients deliver HTML. Email clients support different parts of CSS, so an email template favors tables, inline styles, and safe fallbacks.
Fluid and Hybrid Layouts
A fluid layout uses percentages so its width follows the available screen. A hybrid layout combines fluid widths with a max-width, giving desktop screens a readable limit while allowing narrow screens to shrink.
Use a presentation table for structure. The role="presentation" attribute tells assistive technology that the table is for layout, not data.
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="center">
<table role="presentation" width="600" cellpadding="0" cellspacing="0"
border="0" style="width:100%;max-width:600px;background:#ffffff;">
<tr>
<td style="padding:24px;font:16px/24px Arial,sans-serif;color:#222222;">
Your message content
</td>
</tr>
</table>
</td>
</tr>
</table>The outer table fills the viewport. The inner table is 600 pixels wide on large screens but shrinks to the available width on phones.
Media Queries and Stacking Columns
A media query changes styles when a condition matches. Use it to stack columns on narrow screens. Keep the base layout usable when a client ignores the query.
<style>
@media screen and (max-width: 600px) {
.stack {
display: block !important;
width: 100% !important;
}
}
</style>Apply class="stack" to each column cell. Some clients ignore embedded styles, so each cell should still have a sensible width and padding inline.
Readable Text and Tappable Targets
Use at least 16 pixels for body text and a line height near 1.5 times the font size. Keep paragraphs short. Give links and controls generous padding. A larger tap area reduces accidental taps on phones.
Bulletproof Buttons
Build the button as a table cell containing a padded link. The cell background preserves the button color in clients with limited CSS support.
<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:700 16px/20px Arial,sans-serif;color:#ffffff;text-decoration:none;">
View your order
</a>
</td>
</tr>
</table>Responsive Images and Blocked Images
Set display:block to remove the gap below images. Use width:100%;max-width: so an image shrinks without exceeding its intended size. Always provide useful alt text. If an image is decorative, use alt="".
<img src="https://example.com/banner.jpg"
alt="Blue hiking backpack beside a map"
width="600"
style="display:block;width:100%;max-width:600px;height:auto;border:0;">When images are blocked, the alternative text should still explain the image’s purpose.
Exercise
Why use both width="600" and style="width:100%;max-width:600px;" on an email image?
Show answer
The HTML width supports predictable sizing in email clients, while the CSS lets the image shrink on narrow screens without becoming wider than 600 pixels.