email-html-mjml
Responsive HTML email template generation using MJML 4.x framework. Use when the user asks to create, generate, design, or build an email template — including welcome emails, promotional blasts, transactional templates, newsletters, or any responsive email. Also use when the user asks to compile MJML to HTML, work with or edit existing MJML templates, or troubleshoot email rendering issues across clients.
git clone https://github.com/framix-team/skill-email-html-mjml
T=$(mktemp -d) && git clone --depth=1 https://github.com/framix-team/skill-email-html-mjml "$T" && mkdir -p ~/.claude/skills && cp -r "$T/email-html-mjml" ~/.claude/skills/framix-team-skill-email-html-mjml-email-html-mjml && rm -rf "$T"
email-html-mjml/SKILL.mdemail-html-mjml — Responsive Email Developer
Generate valid, cross-client MJML 4.x templates and compile them to production-ready HTML. The primary goal is compatibility: Outlook (2013–365), Gmail (web/app), Apple Mail, and major mobile clients. Every output must be compilable with
--config.validationLevel=strict and survive Gmail's 102KB clip limit.
Workflow
- Gather requirements — Infer email type, brand colors, and content from the user's message and conversation context. Ask only for what is genuinely missing and blocking progress (e.g., no colors provided and the layout has branded sections). Never front-load a questionnaire.
- Plan layout — Decide and announce the structure before writing code (single-column, 2-col grid, hero + content, etc.)
- Load component references — Read the relevant file(s) from the Component Index below before writing any MJML
- Generate MJML — Write complete, valid MJML starting from
with a full<mjml><mj-head> - Compile — Follow
. Runcompilation.md
withnpx mjml--config.minify=true - Deliver both files — Always output
source AND compiled.mjml.html
9 Engineering Rules
- Structural Integrity — All visual content MUST be in
inside<mj-column>
. Sections cannot be nested.<mj-section> - Responsive Defaults — Assume 600px width. Use
to prevent mobile stacking for side-by-side elements (social bars, logo rows).<mj-group> - Outlook Compatibility — Use
for web fonts (prevents Times New Roman fallback). Always provide a fallback stack (Arial, sans-serif). For<mj-font>
background images, always set both<mj-section>
and a fallbackbackground-size
.background-color - Gmail Optimization — Use
oninline="inline"
for custom CSS. Prefer component attributes (<mj-style>
,color
) over CSS classes for critical styles.font-size - Dark Mode — Include dark mode support when explicitly requested or when the email has a light background that would cause harsh forced-inversion. See the Dark Mode Pattern below.
- Accessibility — Every
MUST have<mj-image>
. Always setalt
(populates<mj-title>
). Maintain WCAG 2.1 AA 4.5:1 contrast. For heading roles, usearia-label
— directmj-html-attributes
/role
attributes onaria-level
are illegal under strict validation (see Accessibility Checklist below).mj-text - Styling Efficiency — Use
with<mj-attributes>
, component defaults, and<mj-all>
to eliminate repetitive inline styles.<mj-class> - Hero Sections — Use
for full-bleed hero banners; it falls back to a regular section in unsupported clients. Avoid<mj-hero>
and<mj-accordion>
— client support is too poor to be useful.<mj-carousel> - Templating Support — Wrap dynamic tags (Handlebars/Liquid) in
to protect them from the MJML parser.<mj-raw>
Critical Gotchas
Outlook:
- Background images: VML only generated for
and<mj-section>
— nowhere else<mj-hero> - Background positioning: keyword values only (
,top
,center
) — pixel values ignoredbottom - Always pair
with explicitbackground-repeat="no-repeat"background-size - Font fallback:
hides<mj-font>
from Outlook via MSO conditional comments@font-face
Gmail:
- Use component attributes for critical layout — CSS classes may be stripped
- 102KB clip: always compile with
--config.minify=true
iOS / Android stacking:
- Always compile with
— removes whitespace between--config.minify=true
columnsinline-block - Whitespace between tags causes stacking even inside
<mj-group>
Vertical-align bug:
- If any column in a section sets
, ALL columns in that section must explicitly set itvertical-align
JavaScript:
- JS is completely blocked in all email clients (Gmail, Outlook, Apple Mail, iOS Mail). No
, no clipboard API, no interactivity of any kind. Interactive-looking elements (copy buttons, toggles) are purely decorative.onclick
Dark Mode Pattern
<mj-head> <mj-raw> <meta name="color-scheme" content="light dark"> <meta name="supported-color-schemes" content="light dark"> </mj-raw> <!-- Light logo visible by default; dark logo hidden --> <mj-style inline="inline"> .dark-logo { display: none !important; } </mj-style> <!-- Dark mode overrides --> <mj-style> @media (prefers-color-scheme: dark) { .light-logo { display: none !important; } .dark-logo { display: block !important; } } </mj-style> </mj-head>
Safe neutrals:
#121212 (not #000000) and #F1F1F1 (not #FFFFFF) — prevents jarring forced inversions.
Accessibility Checklist
is set (screen reader email label +<mj-title>
)aria-label
attribute on rootlang
tag<mjml>
on everyalt
and<mj-image><mj-social-element>- Heading role set via
(NOT as a direct attribute onmj-html-attributes
):mj-text<!-- In mj-head --> <mj-html-attributes> <mj-selector path=".email-heading div"> <mj-html-attribute name="role">heading</mj-html-attribute> <mj-html-attribute name="aria-level">1</mj-html-attribute> </mj-selector> </mj-html-attributes> <!-- On the component --> <mj-text css-class="email-heading" ...>Heading text</mj-text> - 4.5:1 contrast ratio on all text/background pairs
- No text baked into images — always use live
blocks<mj-text>
Component Index
Before writing any MJML, read the component file(s) for the components you'll use.
| Group | Components | Load when | File |
|---|---|---|---|
| Head | mj-attributes, mj-font, mj-style, mj-preview, mj-breakpoint, mj-html-attributes | Setting up head, global styles | |
| Layout | mj-body, mj-section, mj-column, mj-group, mj-wrapper | Building structure / grid | |
| Content | mj-text, mj-image, mj-button, mj-divider, mj-spacer, mj-table | Adding content blocks | |
| Interactive | mj-accordion, mj-carousel, mj-social, mj-navbar | Interactive or social elements | |
| Advanced | mj-hero, mj-raw, mj-include | Hero banners, template tags, partials | |
General reference (hierarchy, ending tags, validation, width math, Gmail clip):
mjml-reference.md
Compilation
Read
compilation.md for the full workflow. Key command:
npx mjml template.mjml -o dist/template.html --config.minify=true --config.validationLevel=strict
Hard rules:
- Never
npm install -g mjml - Always use
ornpx./node_modules/.bin/mjml - If mjml not in
, suggestpackage.jsonnpm install -D mjml
Examples
assets/examples/basic-layout.mjml — MJML docs basic layout example. Covers 6-section structure: company header, image hero + button, intro text, 2-column image+text, 3-column icons, social row. Intentionally bare-bones (no mj-head, no dark mode, placeholder copy) — reflects the MJML docs style. Use as a structural reference for layout patterns only, not as a production template.
Output
Always deliver:
— complete MJML source (editable, version-controllable)<name>.mjml
— compiled output (production-ready, send via ESP)<name>.html
Name files after the email type:
welcome.mjml, promo-sale.mjml, order-confirmation.mjml