HTML Email Classes

In HTML emails, the class attribute is commonly used to group elements under a shared style. While many email clients don’t fully support embedded or external CSS, classes are still useful when used with inline styles or for development workflows that involve inlining CSS automatically.


What is the Class Attribute?

The class attribute allows you to assign a name to an element so it can be styled consistently across multiple parts of your email. You can reuse the same class across elements like <table>, <td>, <div>, and <span>.

However, in production HTML emails, styles should be inlined directly on each element for maximum compatibility.


📌 Example (Before Inlining)

<style>
  .content-block {
    font-family: Arial, sans-serif;
    font-size: 16px;
    color: #333;
    padding: 20px;
    background-color: #f9f9f9;
  }
</style>

<table class="content-block">
  <tr>
    <td>
      <p>Hello and welcome to our newsletter!</p>
    </td>
  </tr>
</table>

👉 In this example, the class="content-block" would be picked up by your CSS in development—but in the final version, styles need to be inlined like this:


✅ Example (After Inlining)

<table style="font-family: Arial, sans-serif; font-size: 16px; color: #333; padding: 20px; background-color: #f9f9f9;">
  <tr>
    <td>
      <p>Hello and welcome to our newsletter!</p>
    </td>
  </tr>
</table>

Why Use Classes in Email?

  • Reusable styling: During development, you can apply styles to multiple elements before inlining.
  • Template organization: Makes your code more readable and maintainable before build tools process it.
  • Framework-friendly: Many email frameworks (like MJML or Maizzle) rely on classes before compiling to inline styles.

Key Tips for Using class in Emails

TipWhy it Matters
🧱 Use in dev, not prodMost email clients ignore <style> tags—especially in the <head>
🔁 Reuse before inliningUse classes to keep dev code DRY (Don’t Repeat Yourself)
✅ Inline everything before sendingEnsures maximum compatibility across Gmail, Outlook, Apple Mail, etc.
🎯 Keep class names shortReduces email size and prevents Gmail clipping
⚠️ Avoid relying on JavaScriptEmail clients don’t support JavaScript, so ignore JS-related uses of class

Multiple Classes in Emails

Just like in web development, you can assign multiple classes to an element:

<td class="footer-text small-text">
  © 2025 Email Technica
</td>

In dev, this helps keep styles modular—but again, all styling should be inlined before deployment.


📌 Summary

  • The class attribute is helpful during the development phase of email design.
  • Use classes to group styles—but always inline styles before sending.
  • Never rely on JavaScript or modern CSS selectors in production HTML emails.
  • Use tools like Email Comb, Maizzle, or PutsMail with inlining to go from class-based dev to email-ready markup.