HTML Email Template

HTML Email Templates (Tables for Layout)

Creating HTML email templates can be a fun and creative process. In this article, we’ll explore why tables are often used for layout in HTML emails and show you how to build a simple template. This guide is designed for beginners, with real-world examples and a friendly, step-by-step approach.

Why Use Tables for Layout in HTML Emails?

Many modern websites use CSS for layout, but email clients often have limited CSS support. This means that complex CSS designs may not render correctly across different email services. To overcome these challenges, developers use HTML tables for layout because:

  • Compatibility: Tables are widely supported by most email clients, including older versions.
  • Consistency: Using tables helps maintain a consistent layout across various email platforms.
  • Simplicity: Tables provide a straightforward structure that is easy to manage for simple designs.

Basic Structure of a Table-Based Email Template

Below is a simple example of an HTML email template that uses tables for layout:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Simple HTML Email</title>
</head>
<body style="margin: 0; padding: 0;">
  <!-- Outer table to center the email -->
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td align="center">
        <!-- Main email container -->
        <table border="0" cellpadding="0" cellspacing="0" width="600" style="border: 1px solid #cccccc;">
          <!-- Header Section -->
          <tr>
            <td align="center" bgcolor="#70bbd9" style="padding: 40px 0 30px 0; font-size: 24px; font-family: Arial, sans-serif; color: #ffffff;">
              Welcome to Our Newsletter!
            </td>
          </tr>
          <!-- Body Section -->
          <tr>
            <td bgcolor="#ffffff" style="padding: 40px 30px 40px 30px; font-family: Arial, sans-serif; font-size: 16px; line-height: 24px;">
              <p>Hello,</p>
              <p>Thank you for subscribing to our newsletter. We are excited to share the latest updates and news with you. Stay tuned for more!</p>
            </td>
          </tr>
          <!-- Footer Section -->
          <tr>
            <td bgcolor="#ee4c50" style="padding: 30px; font-family: Arial, sans-serif; font-size: 14px; color: #ffffff;" align="center">
              &copy; 2025 Your Company. All rights reserved.
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</body>
</html>

Explanation:

  • Outer Table: Centers the main content of the email.
  • Main Container: A table with a fixed width (600px) that holds all sections.
  • Header, Body, Footer: Each section is placed inside its own table row (<tr>) for clear separation.
  • Inline Styles: CSS is added inline to ensure maximum compatibility across email clients.

Real-World Example: Promotional Email

Imagine you’re creating a promotional email for a sale event. You can modify the basic template to include images, buttons, and additional text.

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Big Sale Event!</title>
</head>
<body style="margin: 0; padding: 0;">
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td align="center">
        <table border="0" cellpadding="0" cellspacing="0" width="600" style="border: 1px solid #cccccc;">
          <!-- Header with Sale Banner -->
          <tr>
            <td align="center" bgcolor="#f4a460" style="padding: 40px 0 30px 0;">
              <img src="https://via.placeholder.com/600x200" alt="Sale Banner" width="600" style="display: block;">
            </td>
          </tr>
          <!-- Promotional Content -->
          <tr>
            <td bgcolor="#ffffff" style="padding: 40px 30px 40px 30px; font-family: Arial, sans-serif; font-size: 16px; line-height: 24px;">
              <p>Hi there!</p>
              <p>Don't miss out on our biggest sale of the year. Enjoy discounts up to 50% off on your favorite products. Shop now and save big!</p>
              <p style="text-align: center;">
                <a href="https://www.yourwebsite.com" style="background-color: #f4a460; color: #ffffff; padding: 10px 20px; text-decoration: none; border-radius: 5px;">Shop Now</a>
              </p>
            </td>
          </tr>
          <!-- Footer with Contact Info -->
          <tr>
            <td bgcolor="#f4a460" style="padding: 30px; font-family: Arial, sans-serif; font-size: 14px; color: #ffffff;" align="center">
              &copy; 2025 Your Company. Visit us at <a href="https://www.yourwebsite.com" style="color: #ffffff; text-decoration: underline;">www.yourwebsite.com</a>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</body>
</html>

What’s Happening Here?

  • Sale Banner: An image is used at the top to catch the reader’s eye.
  • Call-to-Action Button: A clickable button encourages users to visit your website.
  • Consistent Styling: All styling is done inline for compatibility.

Tips for Designing HTML Email Templates

  • Keep It Simple: Stick to basic table structures to ensure your email displays correctly on all devices.
  • Use Inline Styles: Always apply CSS inline, as many email clients do not support external stylesheets.
  • Test Your Email: Use email testing tools like Litmus or Email on Acid to see how your template renders in different email clients.
  • Responsive Design: Although tables are used, consider adding media queries (with caution) to improve responsiveness on mobile devices.
  • Fallbacks: Use alt text for images and ensure that your design degrades gracefully if images do not load.

Conclusion

HTML email templates built with tables for layout remain a reliable and efficient solution for ensuring your emails look great across all platforms. By using a simple table-based structure, inline CSS, and testing your design, you can create effective and visually appealing emails. Experiment with different designs and layouts to find what works best for your audience.

Further Reading