New guide: how to warm up a dedicated IP without hurting your reputation. Read now →
Log in
MigoSMTP
Sending and campaignsUpdated 4 Nov 2026

HTML Email Layout: Tables, Inline CSS and Best Practices

Why HTML email still uses tables and inline CSS, how to structure a reliable layout, which CSS to inline, how to automate inlining, and a best-practice checklist for markup, images, links and size.

VR
Written by Valentina Reyes
E-commerce Email Specialist
Reviewed by Daniel Whitfield
  • Published7 Jun 2023
  • Read time7 min
  • Length1,439 words
Share this guide

HTML email layouts are built with tables and inline CSS because email clients, unlike web browsers, strip, rewrite or ignore much of the code they receive. Table-based structure positions content consistently, including in desktop Outlook, which uses a word-processor engine for layout. Inline styles survive clients that remove the style block from the head. Modern CSS layout such as flexbox and grid is unevenly supported in email clients, so tables remain the dependable foundation.

This guide shows how to structure a table layout, what to inline and what to leave in a style block, how to automate inlining, and a checklist covering markup, images, links, accessibility and message size. Client support changes, so confirm any property against a current reference such as caniemail.com.

StructureOuter wrapper table, centred 600 px container, nested tables per section
CSSInline critical styles on each element; keep media queries in a style block
ToolingWrite with a readable source, then inline automatically at build time
CheckSize under about 100 KB, alt text on images, plain text part included

Why tables and inline CSS persist

Problem in email clientsConsequenceTable and inline approach
Style block removed or altered by some clientsUnstyled contentInline styles on elements
Word engine in classic OutlookFloats, margins and positioning failTable cells with explicit widths and padding
Class and selector support variesRules not appliedDirect style attributes
JavaScript and forms are blocked or strippedNo dynamic behaviourUse links and server-side logic
Different default margins and fontsInconsistent spacingExplicit resets on every element

None of this prevents you from using a modern workflow. Write components in a readable format, then compile to table-based, inlined HTML as a build step. The output is for email clients, not for human editing.

A reliable table structure

Use a full-width outer table for background colour, and inside it a centred container table of 600 pixels or less. Add rows for header, hero, body and footer. Where you need columns, nest another table inside a cell. Set role="presentation" so screen readers do not announce layout tables as data, and reset cellpadding, cellspacing and border.

<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background:#f4f4f4;">
 <tr>
  <td align="center" style="padding:24px 12px;">
   <table role="presentation" width="600" cellpadding="0" cellspacing="0" border="0" style="width:600px;max-width:100%;background:#ffffff;">
    <tr>
     <td style="padding:24px;font-family:Arial,Helvetica,sans-serif;font-size:16px;line-height:24px;color:#222222;">
      <h1 style="margin:0 0 12px 0;font-size:24px;line-height:30px;">Order shipped</h1>
      <p style="margin:0 0 16px 0;">Your parcel is on its way.</p>
      <table role="presentation" cellpadding="0" cellspacing="0" border="0">
       <tr>
        <td bgcolor="#0b5fff" style="border-radius:4px;">
         <a href="https://example.com/track" style="display:inline-block;padding:12px 24px;font-family:Arial,sans-serif;font-size:16px;color:#ffffff;text-decoration:none;">Track parcel</a>
        </td>
       </tr>
      </table>
     </td>
    </tr>
   </table>
  </td>
 </tr>
</table>

The button is a table cell with a background colour, with the link inside, a common pattern that works widely. Classic Outlook ignores padding on the link, so for full fidelity use the VML approach in Outlook HTML email rendering.

What to inline and what to keep in a style block

  • Inline: font family, size, colour, line height, margins, padding, background colour, borders, widths and text alignment.
  • Style block in the head: media queries, hover states and resets that are enhancements. Clients that remove the block lose only the enhancement.
  • Attributes alongside CSS: width, height, align, valign and bgcolor on tables and cells help older engines.
  • Avoid: CSS variables, advanced selectors, external stylesheets, shorthand that some clients mishandle and unsupported units.
  • Always set: an explicit font stack on every text-bearing cell, since inheritance is unreliable in some clients.

The properties supported by each client are tabulated in email CSS support. Responsive techniques are in responsive email design.

Automating CSS inlining

Hand-inlining is error-prone. Keep your styles in a normal stylesheet or style block while developing and inline them in a build step. Several libraries do this; Premailer for Python and Juice for Node.js are widely used. The example uses Premailer.

# pip install premailer
from premailer import transform

source = '''
<html><head><style>
  p { margin:0 0 16px 0; font-family:Arial,sans-serif; color:#222; }
  .btn { background:#0b5fff; color:#fff; padding:12px 24px; }
</style></head>
<body><p>Hello</p><a class="btn" href="https://example.com">Open</a></body></html>
'''

inlined = transform(source, keep_style_tags=True, remove_classes=False)
print(inlined)

Check the output rather than trusting it blindly. Inliners can drop rules inside media queries (which is why they usually preserve the style block) or fail on unusual selectors. After inlining, send real test messages as explained in creating and testing HTML email templates.

  1. Use a doctype, lang attribute and meta charset UTF-8, so characters display correctly.
  2. Give each image width, height, alt and style="display:block;border:0;". Write meaningful alt text, since many clients block images by default. See blocked images.
  3. Host images on a reliable HTTPS domain; avoid embedding large data URIs, which many clients do not support.
  4. Make link text descriptive and use full HTTPS URLs. Avoid link shorteners.
  5. Include a plain-text alternative that carries the same message.
  6. Add an unsubscribe link and your postal address where required in marketing email.
  7. Keep a sensible balance of text and images; see text to image ratio.

Common structural patterns

PatternHow to build itNote
Two columnsA table with two cells of fixed width, or the hybrid inline-block techniqueStack on mobile with a media query or hybrid code
Image beside textNested table with an image cell and a text cellSet vertical alignment on both cells
SpacerA cell with explicit height and a non-breaking space or line-height:1pxPrefer padding on cells over spacer images
DividerA cell with a top border or a thin coloured cellAvoid hr styling, which varies
FooterA final row with address, preferences and unsubscribe linksRequired for marketing email in many regions

Treat each section as a self-contained module: a row with its own padding, background and fonts. Modules can then be reordered or removed without breaking neighbours, which is exactly what editors and template systems need. Keep the number of nested levels as low as practical; every extra table adds weight and a chance for a client to misinterpret spacing. For a ready-made approach to repeating sections, header and footer content, see creating and testing HTML email templates.

Naming matters for maintainability. Use consistent comments to mark the start and end of each module in the source, and strip them from the production build to save bytes. Keep brand colours and font stacks in variables in your source files and compile them into the inlined output, so a rebrand is a single change followed by a rebuild and a test round, instead of a search across hand-edited markup.

Accessibility and size

Accessible email is also more robust email. Use semantic headings inside the table cells, sufficient colour contrast, a logical reading order that makes sense when read top to bottom and a language attribute. Avoid text in images alone. For more, see accessible HTML email.

Message size matters: Gmail clips the display of messages over about 102 KB of HTML, hiding the rest behind a link, which can hide your footer and unsubscribe link and remove tracking. Keep HTML lean, strip comments from the production build and avoid duplicating inlined declarations unnecessarily. Check the final size of the compiled file before sending.

Best-practice checklist

  • 600 px or narrower container, centred, with a fluid fallback.
  • Nested tables, role="presentation", no layout reliance on margins on divs.
  • Inline styles on every element that needs them, with a resilient font stack.
  • Media queries in the head only as enhancement.
  • Images with dimensions and alt text; no critical content in images only.
  • A plain-text part and a web version link.
  • Total HTML size well under the clipping threshold.
  • Tested on real clients, in dark mode and with images off.

Troubleshooting

SymptomLikely causeFix
Styles missing in some clientsStyle block strippedInline critical styles
Unexpected gaps between imagesInline image baseline spacingdisplay:block on images
Columns collapse oddlyNested table widths not setSet widths on tables and cells
Footer cut off in GmailHTML over the clipping limitReduce size; remove unused CSS and comments
Inliner removed responsive rulesRules inside media queriesKeep the style block and test the output
Odd charactersWrong charsetDeclare UTF-8 in the head and the MIME header

Send your finished templates Deliver tested HTML email through an SMTP relay or API.

Explore the SMTP relay

References and further reading

Frequently asked questions

Why do HTML emails still use tables?

Table layout renders consistently across email clients, including classic Outlook, where modern CSS layout is unreliable.

Do I need to inline CSS?

Yes for critical styles, because some clients strip or ignore the style block. Keep media queries and enhancements in the head.

How do I inline CSS automatically?

Use a tool such as Premailer for Python or Juice for Node.js as a build step, then check the output in real clients.

How wide should an email be?

A 600 px container is the common maximum, with fluid behaviour on smaller screens.

Why was my email footer cut off in Gmail?

Gmail clips displayed messages above roughly 102 KB of HTML. Reduce markup and unused CSS.

Topics#html email#tables#inline css#layout#best practices
Was this guide helpful?Your answer helps us improve our documentation.

Start sending in minutes.

Create an account, add your domain and send your first email.

Get started Talk to sales