elements man style/emailA mail-safe baseline for HTML emails. This is email.css, imported separately
from the main stylesheet:
Import@import "@elements/ui/email";
In a scaffolded app app/shared/styles/email.css already imports it, and
every email's style.css imports that file.
Why email CSS differs from page CSS
Mail clients (Gmail, Apple Mail, Outlook, web clients) are far stricter than
browsers. They can't reliably resolve CSS custom properties, they support
@media unevenly, and they often demand inline styles. So email.css is written
differently from the rest of the package:
- No CSS variables. Every value is a raw px or hex, so the CSS renders the same in every client with no custom property to resolve.
- No layers, no
@media, no@container. Plain rules only. - Light-only. There's no dark-mode flip. Mail clients apply their own dark mode, and the package's dark mode depends on CSS custom properties, which mail clients can't reliably resolve.
Write any additions to this file the same way: raw values, no vars, no media queries, no layers.
The .email scope
Every rule is scoped under .email, so the baseline never applies to your
website's pages. The email generator tags each email template with
<body class="email <slug>">, so the baseline applies inside emails only.
Classes
| Class | Role |
|---|---|
.email |
The body baseline: system font, 16px/1.55 text, dark ink on white, comfortable page padding |
.email-wrap |
A centered single-column wrapper capped at 560px, so the email reads well on desktop and scales down on mobile without media queries |
.email-footer |
The small-print footer treatment: a top rule, smaller muted text for the sender address, unsubscribe link, and legal |
Bare .email a, .email h1/h2/h3, and .email p are styled too, so basic
email content looks right with no extra classes.
Welcome email<body class="email welcome"> <div class="email-wrap"> <h1>Welcome aboard</h1> <p>Thanks for signing up. Here's how to get started…</p> <div class="email-footer"> <p>Sent by Your Company · <a href="#">Unsubscribe</a></p> </div> </div> </body>
Styling an Email
An email's own rules go in its style.css, scoped under .email.<name>.
These practices render reliably across mail clients:
- Raw values.
pxand hex. Novar(),oklch(),@mediaor@layer. - One column. Everything inside
.email-wrap. Content side by side goes in a<table>: flex and grid render differently from one client to the next. - Under 16 KB of CSS. Gmail drops the whole
<style>above that, so an email never imports a page stylesheet or a UI component's CSS. - Readable with no CSS. The Gmail apps remove
<style>for accounts that are not Gmail. Headings, paragraphs and a plain link carry the message there. - Images with a size. A
widthattribute andalttext on every<img>, so a client that blocks images keeps the layout.
A button is a link with padding and a background:
app/emails/welcome/style.css@import "#app/shared/styles/email.css"; .email.welcome .button { display: inline-block; padding: 12px 20px; border-radius: 6px; background: #2563eb; color: #ffffff; font-weight: 600; text-decoration: none; }
To look at an email while you style it, give it a preview route (see
elements man email).