Sub topic 1
Why Email HTML Is Different From Web HTML
Prerequisites
Assume you know basic HTML and CSS, the CSS box model, media queries, and how email clients deliver HTML messages.
Why Email HTML Is Different From Web HTML
A web browser downloads a page and renders it with a mostly consistent standards-based engine. An email client may sanitize HTML, remove JavaScript, block images, or support only part of CSS. Different clients also use different rendering engines. Desktop Outlook, for example, uses Microsoft Word for much of its HTML rendering.
Design email HTML for graceful degradation. Keep the important content readable when CSS or images fail. Prefer simple structures over modern layout systems such as Flexbox and CSS Grid.
Structuring a Template With Tables
Tables provide predictable rows and columns across older email engines. Use them for layout, not for data, and add role="presentation" so assistive technology does not announce layout tables as data tables.
A common structure has an outer table that spans the viewport and an inner table that contains the message:
| Layer | Purpose |
|---|---|
| Outer table | Full-width background and centering |
| Inner table | Content width and columns |
| Table cells | Padding, alignment, and text |
<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;">
<tr>
<td style="padding:24px;font-family:Arial,sans-serif;">
Order confirmed
</td>
</tr>
</table>
</td>
</tr>
</table>Inline CSS and What a Style Block Can Do
Inline CSS puts essential presentation directly on each element. It survives clients that strip or limit the document’s <style> block. Use an embedded style block for rules that need selectors or media queries, such as changing column widths on narrow screens.
Viewport Meta Tag and Basic Client Resets
The viewport declaration tells mobile clients to use the device width instead of pretending the message is a wide desktop page. A small reset removes default body spacing. Keep critical values inline because resets are not supported everywhere.
<meta name="viewport" content="width=device-width, initial-scale=1">
<body style="margin:0;padding:0;">Exercise
Why should essential styles be inline in an email template?
Show answer
Some clients remove or ignore embedded style blocks, while inline declarations remain attached to the elements they format.