email-html-mjml — responsive cross-client email developer
Generate valid MJML 4.x templates and compile them to production-ready HTML.
Primary goal is compatibility: Outlook (2013–365), Gmail (web/app), Apple Mail,
major mobile clients. Every output must compile with
--config.validationLevel=strict and survive Gmail's 102KB clip limit.
Requires Node.js 14+. Install MJML per-project (npm install -D mjml) — never global.
When to use
User asks to create/design/build an email template (welcome, promo blast,
transactional, newsletter, any responsive email), compile MJML→HTML, edit
existing MJML, or troubleshoot email rendering across clients.
Workflow
- Gather requirements — infer email type, brand colors, content from context.
Ask only for genuinely missing + blocking info. No front-loaded questionnaire.
- Plan layout — decide and announce structure first (single-column, 2-col grid,
hero + content, etc.).
- Load component references — read the relevant component file(s) before writing.
- Generate MJML — complete, valid, starting from
<mjml> with a full <mj-head>.
- Compile —
npx mjml with --config.minify=true.
- Deliver both files —
.mjml source AND compiled .html.
9 engineering rules
- Structural integrity — all visual content in
<mj-column> inside <mj-section>.
Sections cannot be nested.
- Responsive defaults — assume 600px width. Use
<mj-group> to stop mobile
stacking for side-by-side elements (social bars, logo rows).
- Outlook — use
<mj-font> for web fonts (avoids Times New Roman fallback) with
a fallback stack (Arial, sans-serif). For section background images set both
background-size and a fallback background-color.
- Gmail — use
inline="inline" on <mj-style>. Prefer component attributes
(color, font-size) over CSS classes for critical styles (classes get stripped).
- Dark mode — add when requested or when a light background would cause harsh
forced inversion. See pattern below.
- Accessibility — every
<mj-image> needs alt; always set <mj-title>; WCAG
2.1 AA 4.5:1 contrast. Heading roles via mj-html-attributes (direct
role/aria-level on mj-text is illegal under strict validation).
- Styling efficiency — use
<mj-attributes> with <mj-all>, defaults, <mj-class>.
- Hero — use
<mj-hero> for full-bleed banners (falls back gracefully). Avoid
<mj-accordion> and <mj-carousel> (poor client support).
- Templating — wrap dynamic tags (Handlebars/Liquid) in
<mj-raw> to protect
them from the MJML parser.
Critical gotchas
- Outlook background images: VML only generated for
<mj-section> and <mj-hero>,
nowhere else. Positioning uses keyword values only (top/center/bottom) —
pixel values ignored. Always pair background-repeat="no-repeat" with explicit
background-size.
- Gmail 102KB clip: always compile with
--config.minify=true.
- iOS/Android stacking: minify removes whitespace between inline-block columns;
whitespace between tags causes stacking even inside
<mj-group>.
- Vertical-align bug: if any column in a section sets
vertical-align, ALL columns
in that section must explicitly set it.
- JavaScript is fully blocked in all email clients — no
onclick, no interactivity.
"Interactive" elements (copy buttons, toggles) are decorative only.
Dark mode pattern
<mj-head>
<mj-raw>
<meta name="color-scheme" content="light dark">
<meta name="supported-color-schemes" content="light dark">
</mj-raw>
<mj-style inline="inline">.dark-logo { display: none !important; }</mj-style>
<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), #F1F1F1 (not #FFFFFF).
Accessibility checklist
Compilation
npx mjml template.mjml -o dist/template.html --config.minify=true --config.validationLevel=strict
Hard rules: never npm install -g mjml; always npx or ./node_modules/.bin/mjml;
if mjml not in package.json, suggest npm install -D mjml.
Component references
Read the matching reference file from the source repo before writing MJML using
those components (under email-html-mjml/ in the source repo):
components/head.md — mj-attributes, mj-font, mj-style, mj-preview, mj-breakpoint, mj-html-attributes
components/layout.md — mj-body, mj-section, mj-column, mj-group, mj-wrapper
components/content.md — mj-text, mj-image, mj-button, mj-divider, mj-spacer, mj-table
components/interactive.md — mj-accordion, mj-carousel, mj-social, mj-navbar
components/advanced.md — mj-hero, mj-raw, mj-include
mjml-reference.md — hierarchy, ending tags, validation, width math, Gmail clip
compilation.md — full compile workflow
Output
Always deliver both: <name>.mjml (editable source) AND <name>.html (production).
Name files after email type: welcome.mjml, promo-sale.mjml, order-confirmation.mjml.
1---2name: email-html-mjml3description: "Use when creating, generating, designing, or building a responsive HTML email — welcome/promo/transactional/newsletter templates, compiling MJML to HTML, editing existing MJML, or fixing cross-client email rendering (Outlook, Gmail, Apple Mail, mobile)."4version: 1.0.05license: MIT6tags: [mjml, email, html-email, responsive, newsletter, outlook, gmail, transactional, accessibility, dark-mode]7source: https://github.com/framix-team/skill-email-html-mjml8derived_from: awesomeclaude9prerequisites:10 commands: [npx]11metadata:12 source: https://skillmd.com/skills/aashutosh396/email-html-mjml13---1415# email-html-mjml — responsive cross-client email developer1617Generate valid MJML 4.x templates and compile them to production-ready HTML.18Primary goal is compatibility: Outlook (2013–365), Gmail (web/app), Apple Mail,19major mobile clients. Every output must compile with20`--config.validationLevel=strict` and survive Gmail's 102KB clip limit.2122Requires Node.js 14+. Install MJML per-project (`npm install -D mjml`) — never global.2324## When to use2526User asks to create/design/build an email template (welcome, promo blast,27transactional, newsletter, any responsive email), compile MJML→HTML, edit28existing MJML, or troubleshoot email rendering across clients.2930## Workflow31321. Gather requirements — infer email type, brand colors, content from context.33 Ask only for genuinely missing + blocking info. No front-loaded questionnaire.342. Plan layout — decide and announce structure first (single-column, 2-col grid,35 hero + content, etc.).363. Load component references — read the relevant component file(s) before writing.374. Generate MJML — complete, valid, starting from `<mjml>` with a full `<mj-head>`.385. Compile — `npx mjml` with `--config.minify=true`.396. Deliver both files — `.mjml` source AND compiled `.html`.4041## 9 engineering rules42431. Structural integrity — all visual content in `<mj-column>` inside `<mj-section>`.44 Sections cannot be nested.452. Responsive defaults — assume 600px width. Use `<mj-group>` to stop mobile46 stacking for side-by-side elements (social bars, logo rows).473. Outlook — use `<mj-font>` for web fonts (avoids Times New Roman fallback) with48 a fallback stack (Arial, sans-serif). For section background images set both49 `background-size` and a fallback `background-color`.504. Gmail — use `inline="inline"` on `<mj-style>`. Prefer component attributes51 (`color`, `font-size`) over CSS classes for critical styles (classes get stripped).525. Dark mode — add when requested or when a light background would cause harsh53 forced inversion. See pattern below.546. Accessibility — every `<mj-image>` needs `alt`; always set `<mj-title>`; WCAG55 2.1 AA 4.5:1 contrast. Heading roles via `mj-html-attributes` (direct56 `role`/`aria-level` on `mj-text` is illegal under strict validation).577. Styling efficiency — use `<mj-attributes>` with `<mj-all>`, defaults, `<mj-class>`.588. Hero — use `<mj-hero>` for full-bleed banners (falls back gracefully). Avoid59 `<mj-accordion>` and `<mj-carousel>` (poor client support).609. Templating — wrap dynamic tags (Handlebars/Liquid) in `<mj-raw>` to protect61 them from the MJML parser.6263## Critical gotchas6465- Outlook background images: VML only generated for `<mj-section>` and `<mj-hero>`,66 nowhere else. Positioning uses keyword values only (`top`/`center`/`bottom`) —67 pixel values ignored. Always pair `background-repeat="no-repeat"` with explicit68 `background-size`.69- Gmail 102KB clip: always compile with `--config.minify=true`.70- iOS/Android stacking: minify removes whitespace between inline-block columns;71 whitespace between tags causes stacking even inside `<mj-group>`.72- Vertical-align bug: if any column in a section sets `vertical-align`, ALL columns73 in that section must explicitly set it.74- JavaScript is fully blocked in all email clients — no `onclick`, no interactivity.75 "Interactive" elements (copy buttons, toggles) are decorative only.7677## Dark mode pattern7879```xml80<mj-head>81 <mj-raw>82 <meta name="color-scheme" content="light dark">83 <meta name="supported-color-schemes" content="light dark">84 </mj-raw>85 <mj-style inline="inline">.dark-logo { display: none !important; }</mj-style>86 <mj-style>87 @media (prefers-color-scheme: dark) {88 .light-logo { display: none !important; }89 .dark-logo { display: block !important; }90 }91 </mj-style>92</mj-head>93```9495Safe neutrals: `#121212` (not `#000000`), `#F1F1F1` (not `#FFFFFF`).9697## Accessibility checklist9899- `<mj-title>` set; `lang` on root `<mjml>`; `alt` on every image + social element.100- Heading role via `mj-html-attributes` (NOT direct attribute on `mj-text`):101 ```xml102 <mj-html-attributes>103 <mj-selector path=".email-heading div">104 <mj-html-attribute name="role">heading</mj-html-attribute>105 <mj-html-attribute name="aria-level">1</mj-html-attribute>106 </mj-selector>107 </mj-html-attributes>108 <!-- component: <mj-text css-class="email-heading">Heading</mj-text> -->109 ```110- 4.5:1 contrast on all text/background pairs. No text baked into images.111112## Compilation113114```bash115npx mjml template.mjml -o dist/template.html --config.minify=true --config.validationLevel=strict116```117118Hard rules: never `npm install -g mjml`; always `npx` or `./node_modules/.bin/mjml`;119if mjml not in `package.json`, suggest `npm install -D mjml`.120121## Component references122123Read the matching reference file from the source repo before writing MJML using124those components (under `email-html-mjml/` in the source repo):125126- `components/head.md` — mj-attributes, mj-font, mj-style, mj-preview, mj-breakpoint, mj-html-attributes127- `components/layout.md` — mj-body, mj-section, mj-column, mj-group, mj-wrapper128- `components/content.md` — mj-text, mj-image, mj-button, mj-divider, mj-spacer, mj-table129- `components/interactive.md` — mj-accordion, mj-carousel, mj-social, mj-navbar130- `components/advanced.md` — mj-hero, mj-raw, mj-include131- `mjml-reference.md` — hierarchy, ending tags, validation, width math, Gmail clip132- `compilation.md` — full compile workflow133134## Output135136Always deliver both: `<name>.mjml` (editable source) AND `<name>.html` (production).137Name files after email type: `welcome.mjml`, `promo-sale.mjml`, `order-confirmation.mjml`.