Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

CSS for Email | CSS Basics to Advanced lesson | BraveProgrammer
  1. Courses
  2. /
  3. CSS Basics to Advanced

Lesson 37 of 50

·css

CSS for Email

10 mins

Course progress74%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • Inline every rule; external CSS files are ignored by many clients.
  • Use `width` attributes on `<table>`/`<td>` to control layout.
  • Test with **Litmus**, **Email on Acid**, or the free **Mailtrap** sandbox.

Email clients are a fragmented ecosystem. While modern webmail supports most CSS, legacy clients (Outlook 2007‑2019, Gmail mobile) fall back to a much smaller feature set.

Guiding Principles

  1. Inline every declaration – most clients strip <style> blocks.
  2. Avoid advanced layout – no Flexbox, Grid, or position:fixed.
  3. Use tables for structural layout – they render consistently.
  4. Keep the overall width ≤ 600 px to accommodate mobile clients.
  5. Add a plain‑text fallback (multipart/alternative).

Minimal Example – Promotional Banner

<table width="100%" cellpadding="0" cellspacing="0" border="0" style="font-family:Arial,sans-serif; background:#0066cc; color:#fff;">
  <tr>
    <td align="center" style="padding:20px;">
      <h1 style="margin:0; font-size:24px;">Special Offer</h1>
      <p style="margin:10px 0; font-size:16px;">Save 30% today!</p>
      <a href="https://example.com" style="display:inline-block; background:#ff6600; color:#fff; padding:10px 20px; text-decoration:none; font-weight:bold;">Shop Now</a>
    </td>
  </tr>
</table>

Testing Tools

  • Litmus – Full client matrix, screenshot comparison.
  • Email on Acid – Similar test suite, includes spam‑filter analysis.
  • Mailtrap – Free sandbox to capture outgoing email for quick checks.

Common Gotchas

IssueSymptomFix
CSS reset ignoredMargins/paddings appear wrongInline margin:0; padding:0; on <td>/<table>
Images breakNo display:block causing gapsAdd display:block; on images
Links appear invisibleDefault link colour overriddenInline color:#fff; on <a>

Pro Tip – Use <mjml> or Foundation for Emails

These frameworks let you write semantic markup (e.g., <mj-section>) that compiles to fully‑inlined HTML, saving hours of manual fiddling.

Accessibility

  • Provide alt text for every image.
  • Keep a plain‑text version; some clients (plain‑text only) will display it.
  • Ensure sufficient colour contrast; Outlook may ignore background images.
Make it stickPractice what you've learned1 quiz · 6 practical tests · Optional activities from CSS Basics to AdvancedBrowse activities
Previous lessonPrint StylesheetsContinue to lesson 38CSS Performance – Critical CSS & Unused CSSBack to CSS Basics to Advanced curriculum