DevTools Logo

Email CSS Inliner

Email CSS Inliner

Inline CSS into style attributes so Gmail and Outlook keep your email's look.

Runs in your browser
5 declaration(s) inlined · 0 override(s) · 2 rule(s) reported
Try an example

Email HTML

5 lines · 153 chars

CSS to inline

5 lines · 192 chars

Inlined HTML

5 inlined
a:hover: Selector is not a single element/class/id; kept in a style block.
@media (max-width:600px) { .card { padding: 8px; } }: At-rule preserved; email clients apply it in the head.

Details

Gmail and several webmail clients strip <style> blocks, so emails designed with a stylesheet can arrive unstyled. This inliner applies element, class and ID rules to matching tags' style attributes, respecting cascade specificity and !important, while leaving existing inline styles intact. Selectors that cannot be inlined — pseudo-classes, descendant selectors and at-rules — are listed in the report so you know what still depends on the head style block. Your template never leaves the browser.

More examples

Newsletter card

.card { background: #fff; padding: 16px }
h1 { color: #222 }

Each matching tag gets a style attribute; the HTML structure is otherwise unchanged.

Important override

<p style='color: blue'>Hi</p>
p { color: red !important }

An existing inline style normally wins; !important replaces it and the report counts the override.

Hover and media rules

a:hover { color: red }
@media (max-width:600px) { .card { padding: 8px } }

These rules cannot be represented as inline styles, so they are reported rather than silently discarded.

Examples

Newsletter card

Input
.card { background: #fff; padding: 16px } plus <div class='card'>
Output
<div class='card' style='background: #fff; padding: 16px'>

The class rule becomes a style attribute without changing the surrounding markup.

Important override

Input
<p style='color: blue'>Hi</p> plus p { color: red !important }
Output
<p style='color: red'>Hi</p>

Only !important beats an existing inline declaration; the override is counted in the report.

Hover rule

Input
a:hover { color: red }
Output
Reported as not inlinable

Pseudo-classes cannot exist in an inline style attribute, so silently dropping them would mislead you.

Media query

Input
@media (max-width:600px) { .card { padding: 8px } }
Output
At-rule preserved in the report; no inline change

Many mobile email clients still apply media queries from the head; the rule is reported, never silently lost.

About this tool

Email CSS Inliner applies stylesheet rules to the matching tags in your email template, writing them into style attributes. This is the compatibility layer Gmail, Outlook and many webmail clients need, because they strip or ignore a <style> block in the message body.

Element, class and ID selectors are resolved with normal specificity, and existing inline styles keep their priority unless a rule uses !important. The report lists every rule that cannot be inlined — hover states, descendant selectors, at-rules — so you can decide whether to keep it in the head block or replace it with an email-safe alternative.

The tool changes only style attributes: comments, conditional Outlook blocks, table structure and links stay exactly as pasted. Templates are processed entirely in the browser and are never uploaded.

What this tool does not do

  • Only single element, class and ID selectors are inlined; complex selectors are reported, not transformed.
  • At-rules such as @media are reported but not injected into the document head.
  • CSS custom properties are left literal and are not resolved.
  • JavaScript, remote images and linked stylesheets are neither fetched nor executed.
  • Layout-affecting email client quirks (for example Outlook's Word renderer) are outside the tool's scope.

How to use this tool

  1. Paste the HTML

    Copy the email template into the Email HTML pane. Conditional comments and links are preserved.

  2. Paste the CSS

    Copy the contents of your <style> block or linked stylesheet into the CSS pane. At-rules are recognized.

  3. Review the report

    Check the inlined/override counts and the reported pseudo-class or media rules that still need a head style block.

  4. Copy the result

    Copy or download the inlined HTML for your email service provider or ESP template.

Use cases

ESP templates

Prepare HTML for Mailchimp, Customer.io or custom sending infrastructure.

Transactional email

Make password resets and receipts look consistent across Gmail and Outlook.

Design handoff

Turn a styled HTML mockup into email-safe markup with a transparent report.

Debugging

Find rules that email clients cannot honor before a campaign ships.

Selector handling

SelectorBehavior
p, h1, tdInlined on every matching tag
.classInlined on tags carrying the class
#idInlined with higher specificity than classes
a:hover, :focusReported as not inlinable; keep in the head style block
@media (…)Recognized and reported; mobile clients may still honor it
Existing style attributeKept unless an !important rule overrides it

CSS custom properties are kept literally because most email clients do not resolve them.

Common mistakes

Mistake:Expecting hover and descendant selectors to work inline.

Fix:They cannot become style attributes; keep them in a head style block or use email-safe alternatives.

Mistake:Assuming CSS variables resolve in Gmail.

Fix:Most clients do not support custom properties; use literal values in email CSS.

Mistake:Overwriting inline styles unintentionally.

Fix:The inliner keeps existing declarations unless a matching rule is marked !important.

Mistake:Running an inliner over conditional Outlook comments as CSS.

Fix:Conditional comments are preserved verbatim and never parsed as styles.

Mistake:Uploading a template to a random online service.

Fix:This tool performs the transformation locally; nothing leaves the browser.

Frequently asked questions

Why do HTML emails still need inline style attributes?

Several email clients—including Gmail clip views, forwarding views, and legacy enterprise clients—strip or partially ignore <style> blocks, so writing declarations onto element style attributes preserves layout and typography.

What happens to @media queries and :hover rules?

Media queries and pseudo-classes cannot be expressed inside an inline style='' attribute; the inliner preserves <style> blocks when configured and lists non-inlinable selectors explicitly in the diagnostics report.

How are specificity and !important resolved?

Matching element, class, and ID rules merge according to CSS cascade specificity and source order, with existing inline styles winning unless a stylesheet rule carries !important.

Is my HTML newsletter template uploaded to a server?

No. CSS parsing, cascade resolution, and HTML serialization run entirely in your browser.

References & standards