HTML Email and Legacy Constraints

Intermediate · 35 min

Why HTML email still uses nested tables and inline styles, what role=presentation does for them, and how to build for clients you cannot control.

Before thisHTML Performance and Rendering CostTable Structure and When to Use Tables

Responsive HTML Email · 44 min · from 4:57

HTML Email and Legacy Constraints

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by Responsive HTML EmailReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • Email clients are not browsers. Each renders HTML with its own engine and its own limits on CSS, so email authors use the HTML of about two decades ago: tables for layout, attributes for sizing, and inline styles.
  • Layout tables should carry `role="presentation"`. In a test it collapsed a table into generic nodes in Chromium's accessibility tree, while a bare layout table was kept as a `LayoutTable`.
  • Table `width` attributes still lay out in a browser, which is why they work as a baseline in email: a 600px wrapper with two `width="50%"` cells measured 297px per cell.
  • Outlook-only markup is written inside `<!--[if mso]> … <![endif]-->` comments. Browsers treat those as comments, so the content was not rendered in a test.
  • You cannot test email by opening it in your browser. Send it to real clients or use a preview service, and keep the content readable with images and CSS stripped.

Writing for a renderer you cannot see

On the web you test in a few browsers, and they all follow the same standards. Email breaks that. The same message is displayed by Gmail’s web and app renderers, Apple Mail, several Outlook engines (one of them built on Microsoft Word’s layout code), and webmail that rewrites your CSS. Many strip <style> blocks, ignore some properties, and block remote images by default.

So email HTML is a fossil record: tables for layout, width and align attributes, inline styles, and defensive tricks. It is the clearest example of a legacy constraint, a case where the reader’s software, not the standard, sets the rules. The table lessons (structure) say tables are for data on the web; email is where that rule is knowingly broken.

What a browser still does with email markup

I wrote a small email-style skeleton and ran it in Chromium 159 to check the parts that don’t depend on a client.

<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#eeeeee">
  <tr><td align="center">
    <table role="presentation" width="600" style="max-width:600px">
      <tr><td width="50%">Left</td><td width="50%">Right</td></tr>
    </table>
  </td></tr>
</table>
  • The width="50%" cells inside the 600px table measured 297px each, so attribute-based sizing still works, which is why it is the baseline across clients.
  • With role="presentation", the accessibility tree showed the cells as generic nodes. A comparison table without the role was kept as a LayoutTable with rows and cells. Add the role to every layout table so screen readers do not announce a grid. Real data tables should keep their semantics (accessible tables).
  • An <!--[if mso]> … <![endif]--> block, used to give Outlook a fallback, rendered nothing in the browser because it is a comment.

I did not test any real email client, and I can’t say how Outlook, Gmail or Apple Mail will treat this markup. Their support changes, and the Can I email site is the place to look up a specific property.

Habits that follow

  • Inline critical styles. Many tools inline CSS for you at build time. Don’t rely on <style> surviving.
  • Fixed width, centred. About 600px, with max-width for modern clients and a table fallback for older ones.
  • Live text and real alt. Images are often blocked. Keep key content as text, and put background colours behind any white text on an image.
  • Plain-text part and a preview. Send a text alternative, and set a short preheader.
  • Test in clients. Services render previews across engines; at minimum send to a few real accounts.
  • Accessibility still applies. Set lang on html, keep heading order and contrast, and use role="presentation" as above. The language lesson is the same attribute.

Performance rules differ too: keep the total HTML small (Gmail clips long messages) and avoid heavy images. Frameworks such as MJML or Maizzle generate the table markup for you, though I did not test them here.

What the video covers

This clip, 4:57 to 40:05 of Responsive HTML Email’s “The RIGHT WAY to Build HTML Email Templates” (July 2021, about 44 minutes), builds an email template from HTML and CSS. The chapters in the clip cover centring the template, the header two-column table, a logo, social icons, a banner, a three-column section, a dark two-column section, button CSS, a single-column text section and the footer. I skipped the start, which holds a course promotion and setup, and the end, which covers image hosting and testing with Litmus Putsmail. I could not read a transcript. The channel promotes a paid email course, and the video is from 2021, so check support claims against current data. It is the only usable English pick I found for this node and is the weakest fit in the batch.

Where this fits

This follows performance and the earlier table lessons. The last lesson, writing maintainable HTML, is about the opposite end: markup you control.

Check yourself

  1. 01Why does a good HTML email use nested tables where a web page would use CSS grid?

    Email clients, notably desktop Outlook, ignore or mangle modern layout CSS. Tables with width attributes and inline styles lay out the same almost everywhere. The video's approach, building a template from tables and CSS, reflects that.

  2. 02What does `role="presentation"` do on a layout table, and why add it?

    It tells assistive technology the table is only for layout. In a test the table's cells became generic nodes, with no table, row or cell roles. Without it, Chromium kept a layout table node, and screen readers may announce row and column structure.

  3. 03A `<!--[if mso]>` block holds a fallback table for Outlook. What does Chrome do with it?

    Treats it as an ordinary comment. In a test its text was absent from the rendered page. Only Outlook's Word-based engine reads the block.

  4. 04How do you check that an email still works if the client blocks images?

    Turn images off in a test client and read the message. Real `alt` text, background colours behind white text, and live text instead of text baked into images keep it usable.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark