<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Keshur Gojiya</title>
    <description>The latest articles on DEV Community by Keshur Gojiya (@keshurgojiya).</description>
    <link>https://dev.to/keshurgojiya</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4285868%2F589bdc59-7b3c-49b1-bf97-236a490bce7b.jpg</url>
      <title>DEV Community: Keshur Gojiya</title>
      <link>https://dev.to/keshurgojiya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/keshurgojiya"/>
    <language>en</language>
    <item>
      <title>Interactive Elements in HTML Email: What Works Where</title>
      <dc:creator>Keshur Gojiya</dc:creator>
      <pubDate>Sun, 06 Dec 2026 06:22:12 +0000</pubDate>
      <link>https://dev.to/keshurgojiya/interactive-elements-in-html-email-what-works-where-241b</link>
      <guid>https://dev.to/keshurgojiya/interactive-elements-in-html-email-what-works-where-241b</guid>
      <description>&lt;p&gt;Interactive elements in HTML email are possible, but each one works in a different set of email clients: hover effects in Apple Mail and most webmail, CSS tabs and accordions mainly in Apple Mail and Yahoo, AMP mainly in Gmail and Yahoo, and video almost only in Apple Mail. The safe way to use them is to build a complete static email first, then add interactivity as an extra layer that unsupported clients simply ignore. Here is where each technique works, and the fallback I use for each.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hover effects: the safest interactivity in email
&lt;/h2&gt;

&lt;p&gt;According to caniemail and Google's Gmail documentation, &lt;code&gt;:hover&lt;/code&gt; works in Apple Mail and iOS Mail, Gmail on the web and in the Android app (with Google accounts), Yahoo Mail and Samsung Email. Outlook.com and new Outlook apply it only to plain element selectors such as &lt;code&gt;a:hover&lt;/code&gt;. Classic Outlook for Windows and the Gmail iOS app ignore it. Gmail also removes &lt;code&gt;transition&lt;/code&gt; and &lt;code&gt;transform&lt;/code&gt;, so keep the effect to colour, background and underline changes.&lt;/p&gt;

&lt;p&gt;Phones have no hover, so never put information only in a hover state. Use it as polish on a button that already works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
  &lt;span class="nc"&gt;.btn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nt"&gt;hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#0b57d0&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nc"&gt;.btn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nt"&gt;hover&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;underline&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;table&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"presentation"&lt;/span&gt; &lt;span class="na"&gt;cellpadding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;cellspacing&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;border&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"btn"&lt;/span&gt; &lt;span class="na"&gt;bgcolor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#1a73e8"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"background-color:#1a73e8; border-radius:4px; padding:12px 24px;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://example.com/sale"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"color:#ffffff; font-family:Arial, sans-serif; font-size:16px; font-weight:bold; text-decoration:none;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Shop the sale&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;!important&lt;/code&gt; is needed because inline styles normally win over a &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; block. Clients that ignore &lt;code&gt;:hover&lt;/code&gt; show the normal blue button, which is a complete fallback.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS tabs, accordions and carousels with checkboxes
&lt;/h2&gt;

&lt;p&gt;Email tabs, accordions, carousels and "tap to reveal" swaps need no JavaScript. A hidden &lt;code&gt;&amp;lt;input type="checkbox"&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;input type="radio"&amp;gt;&lt;/code&gt; sits before the content, the reader taps its &lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt;, and a CSS rule combining &lt;code&gt;:checked&lt;/code&gt; with a sibling selector (&lt;code&gt;+&lt;/code&gt; or &lt;code&gt;~&lt;/code&gt;) shows, hides or swaps the content.&lt;/p&gt;

&lt;p&gt;Support is narrow. In caniemail's tests, &lt;code&gt;:checked&lt;/code&gt; works in Apple Mail on Mac and iPhone, Yahoo Mail, AOL, Samsung Email and Thunderbird, and only partly in Outlook.com and the Outlook mobile apps. Gmail removes every pseudo-class except &lt;code&gt;:hover&lt;/code&gt;, so these effects do nothing anywhere in Gmail, and classic Outlook for Windows doesn't support form inputs at all.&lt;/p&gt;

&lt;p&gt;Make the fallback the default: every panel or slide visible, stacked like a normal email. The common mistake is hiding content with a plain rule such as &lt;code&gt;.panel { display: none; }&lt;/code&gt; and relying on &lt;code&gt;:checked&lt;/code&gt; to reveal it. Gmail keeps the hiding rule, drops the revealing one, and the content is gone. Let only &lt;code&gt;:checked&lt;/code&gt; hide things instead: start the checkbox checked, hide the panel with &lt;code&gt;.toggle:checked + .panel { display: none; }&lt;/code&gt;, and the reader's tap unchecks it to open the panel. Clients that drop &lt;code&gt;:checked&lt;/code&gt; simply show everything.&lt;/p&gt;

&lt;h2&gt;
  
  
  AMP for Email: real interactivity, limited reach
&lt;/h2&gt;

&lt;p&gt;AMP for Email adds a third version of the message (a &lt;code&gt;text/x-amp-html&lt;/code&gt; MIME part) next to the HTML and plain-text parts, with carousels, accordions, forms that submit inside the email and content that updates when it's opened.&lt;/p&gt;

&lt;p&gt;It works in Gmail on the web (in supported browsers) and in the Gmail apps for Android and iOS, in Yahoo Mail on the web and in its apps, in AOL webmail, and in Mail.ru. Apple Mail and Outlook don't support it; Microsoft ended its Outlook.com AMP preview in 2020.&lt;/p&gt;

&lt;p&gt;Before you can send it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Register each sender address with Google.&lt;/strong&gt; Google wants a real, production-quality email with the AMP part, sent from your production servers and authenticated with SPF, DKIM and DMARC. Registration is per sender address, not per domain, and Yahoo has its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use an email platform that can send the AMP part.&lt;/strong&gt; Not all of them can.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep a full HTML version.&lt;/strong&gt; Gmail shows it whenever AMP can't be displayed, including once the email is more than 30 days old, and forwarding removes the AMP part.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You end up building and testing two emails, which makes sense for in-email booking, quizzes or live stock levels sent to a Gmail-heavy list, and rarely for a regular newsletter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Animated GIFs: motion that works almost everywhere
&lt;/h2&gt;

&lt;p&gt;Animated GIFs play in nearly every client, making them the most reliable way to add motion. The exception is classic Outlook for Windows: Outlook 2007 to 2013 shows only the first frame, and Microsoft 365 versions play GIFs by default but still show only the first frame when animations are switched off in Windows settings.&lt;/p&gt;

&lt;p&gt;So put the key message and the call to action in the first frame, and keep the file small enough to load quickly on a phone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Live countdown timers
&lt;/h2&gt;

&lt;p&gt;A countdown timer is an image, not code: the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; points to a server that draws a fresh GIF with the remaining time whenever the image is requested, so it works wherever images load.&lt;/p&gt;

&lt;p&gt;Two caveats. Some clients cache images, Apple Mail Privacy Protection being the best-known case, so a reopened email can show an out-of-date count. And readers with images off see nothing. Always write the deadline in live text too ("Sale ends Friday at 6 pm GMT") and put it in the alt text.&lt;/p&gt;

&lt;h2&gt;
  
  
  Video in email
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; element plays in Apple Mail on Mac, in iOS Mail (only with the &lt;code&gt;controls&lt;/code&gt; attribute, and without autoplay), in Samsung Email (with controls) and partly in Outlook for Mac. Gmail, classic Outlook, Outlook.com and Yahoo Mail don't play it.&lt;/p&gt;

&lt;p&gt;The reliable approach is a still frame (or a short GIF) of the video with a play button drawn in, linked to the video page. Every reader sees it, and you can track the click.&lt;/p&gt;

&lt;h2&gt;
  
  
  Forms, polls and surveys in email
&lt;/h2&gt;

&lt;p&gt;Forms are the riskiest interactive element. Classic Outlook doesn't support them. Outlook.com and new Outlook show the fields but don't submit them. Gmail submits on the web and in the Android app, but not in the iOS app with non-Google accounts. Readers have also learned to distrust emails that ask them to type in details.&lt;/p&gt;

&lt;p&gt;A link-based poll does the same job in every client. Make each answer a separate link or button with the answer in its URL, and let the landing page record the vote. Some corporate security filters open links automatically before the reader does, so treat raw click counts with some caution.&lt;/p&gt;

&lt;h2&gt;
  
  
  When is an interactive email worth it?
&lt;/h2&gt;

&lt;p&gt;Interactivity is worth it when it helps the reader act faster or shows more in less space: product tabs, an FAQ accordion, a before-and-after image swap, a countdown for a real deadline. It rarely is when most of your list will see the fallback, when the email is rebuilt every week, or when the effect is decoration.&lt;/p&gt;

&lt;p&gt;A simple test: if the interactive part vanished, would the email still do its job? It must. For most &lt;a href="https://keshurgojiya.com/services/html-email-templates" rel="noopener noreferrer"&gt;HTML email templates&lt;/a&gt; I build, the interactivity that earns its place is a hover state on buttons and a GIF with its message in the first frame.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to test interactive emails
&lt;/h2&gt;

&lt;p&gt;Screenshot services capture still images, so they show the fallback but not the interaction. Test with real sends: hover in Gmail on the web and Apple Mail on a Mac, taps on an iPhone, and the fallback in the Gmail apps and classic Outlook, where nothing should be hidden or broken.&lt;/p&gt;

&lt;p&gt;Before sending, run the code through the &lt;a href="https://keshurgojiya.com/tools/html-email-checker" rel="noopener noreferrer"&gt;HTML email checker&lt;/a&gt;. It flags forms, video, scripts and CSS that Gmail or classic Outlook ignore, so you know where your fallback will appear. For AMP, Gmail's developer settings (Settings, General, Dynamic email) let you allow a sender and test AMP emails in your own account before registering.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can you use JavaScript in an HTML email?
&lt;/h3&gt;

&lt;p&gt;No. Email clients don't run JavaScript inside messages, for security reasons. Interactivity in email comes from CSS, AMP, images generated on the fly, or links to a web page.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I embed a YouTube video in an email?
&lt;/h3&gt;

&lt;p&gt;Not as a playable player in the clients most people use. Link a thumbnail with a play button to YouTube or a landing page instead. If your audience is mostly Apple Mail, an HTML &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; with an image fallback is an option.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is AMP for Email still supported?
&lt;/h3&gt;

&lt;p&gt;Yes. Google's developer documentation still covers AMP for Email in Gmail on the web, Android and iOS, and Yahoo supports it in Yahoo Mail and AOL webmail. Outlook and Apple Mail don't, so every AMP email still needs a complete HTML version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Build the static email first; interactivity is an extra layer that must fail gracefully.&lt;/li&gt;
&lt;li&gt;Hover effects and animated GIFs are the safest choices; put the GIF's key message in its first frame.&lt;/li&gt;
&lt;li&gt;CSS checkbox effects skip Gmail and classic Outlook entirely, and AMP needs registration and a second version.&lt;/li&gt;
&lt;li&gt;Replace video and forms with linked images and link-based polls to reach every reader.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This article was first published on &lt;a href="https://keshurgojiya.com/blog/interactive-elements-html-email" rel="noopener noreferrer"&gt;keshurgojiya.com&lt;/a&gt;. I'm Keshur Gojiya, a web developer and HTML email specialist. More guides and free email tools: &lt;a href="https://keshurgojiya.com/tools" rel="noopener noreferrer"&gt;keshurgojiya.com/tools&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>email</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Dark Mode HTML Email: How to Code, Design and Test</title>
      <dc:creator>Keshur Gojiya</dc:creator>
      <pubDate>Sun, 06 Dec 2026 06:10:13 +0000</pubDate>
      <link>https://dev.to/keshurgojiya/dark-mode-html-email-how-to-code-design-and-test-2a31</link>
      <guid>https://dev.to/keshurgojiya/dark-mode-html-email-how-to-code-design-and-test-2a31</guid>
      <description>&lt;p&gt;A dark mode HTML email has to survive three behaviours: some email clients leave your colours alone, some recolour only light backgrounds and dark text (partial inversion), and some recolour everything (full inversion). You can take control only in clients that support the &lt;code&gt;color-scheme&lt;/code&gt; meta tag and &lt;code&gt;@media (prefers-color-scheme: dark)&lt;/code&gt;, mainly Apple Mail and Outlook.com. Everywhere else, including the Gmail apps, the fix is design: colours, images and contrast that still work after the client changes them.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do email clients handle dark mode?
&lt;/h2&gt;

&lt;p&gt;Each client decides for itself, and the behaviour changes with app updates. Based on Google's documentation and Litmus's testing (February 2025):&lt;/p&gt;

&lt;h3&gt;
  
  
  No change
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gmail on the web.&lt;/strong&gt; Dark theme darkens the Gmail interface, but Google says email bodies are rendered on a light background by default.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apple Mail on iPhone, iPad and Mac.&lt;/strong&gt; A normal HTML email stays as designed unless you add the dark mode meta tags. Once you declare dark mode support, Apple Mail applies your dark styles, and if you declare it without writing any, it darkens the email itself.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Yahoo Mail and AOL.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Partial inversion
&lt;/h3&gt;

&lt;p&gt;The client darkens light backgrounds and lightens dark text but leaves dark areas, such as a dark button, mostly alone. Litmus puts &lt;strong&gt;Outlook.com&lt;/strong&gt;, the &lt;strong&gt;Outlook apps for iOS and Android&lt;/strong&gt;, &lt;strong&gt;Outlook for Mac&lt;/strong&gt; and the &lt;strong&gt;Gmail app for Android&lt;/strong&gt; here. The new Outlook for Windows renders much like Outlook.com.&lt;/p&gt;

&lt;h3&gt;
  
  
  Full inversion
&lt;/h3&gt;

&lt;p&gt;The client recolours light and dark areas alike. Litmus lists the &lt;strong&gt;Gmail app for iOS&lt;/strong&gt; and &lt;strong&gt;classic Outlook for Windows&lt;/strong&gt; (Microsoft 365 and Outlook 2021) here.&lt;/p&gt;

&lt;p&gt;Microsoft also lets readers switch back: a sun button in classic Outlook turns the message background white, and a "Turn on the lights" button in Outlook.com and the new Outlook shows the original formatting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dark mode meta tags and prefers-color-scheme
&lt;/h2&gt;

&lt;p&gt;To opt in to dark mode where clients allow it, declare support in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; and write dark styles inside a media query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"color-scheme"&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"light dark"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"supported-color-schemes"&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"light dark"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nt"&gt;root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;color-scheme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;light&lt;/span&gt; &lt;span class="n"&gt;dark&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;supported-color-schemes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;light&lt;/span&gt; &lt;span class="n"&gt;dark&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;prefers-color-scheme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;dark&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nc"&gt;.email-bg&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#121212&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nc"&gt;.email-card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#1e1e1e&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nc"&gt;.email-text&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#e6e6e6&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nc"&gt;.email-link&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#8ab4f8&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put the classes on cells and links that also carry inline light-mode styles; &lt;code&gt;!important&lt;/code&gt; lets the dark styles override them.&lt;/p&gt;

&lt;p&gt;Where it works, according to caniemail:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;prefers-color-scheme:&lt;/strong&gt; Apple Mail on Mac, iPhone and iPad, Outlook.com, Outlook for Mac, iOS and Android, and Samsung Email. Results in the Outlook apps have varied between tests, so check them. Gmail removes the query, and classic Outlook for Windows and Yahoo Mail ignore it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The meta tag and CSS property:&lt;/strong&gt; Apple Mail on Mac honours the meta tag, and caniemail confirms the CSS &lt;code&gt;color-scheme&lt;/code&gt; property on the root element in Apple Mail on Mac and iPhone. That's why the sample sets both.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Gmail is the exception worth knowing. Google's Gmail CSS documentation says the Gmail apps ignore dark mode CSS, but for Google accounts they respect &lt;code&gt;&amp;lt;meta name="color-scheme" content="light only"&amp;gt;&lt;/code&gt;, which stops the apps recolouring your email. It's an either/or choice: the tag can't say "light dark" and "light only" at once, and "light only" means readers who chose dark mode get a bright email in Gmail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Outlook.com's data-ogsc and data-ogsb selectors
&lt;/h2&gt;

&lt;p&gt;When Outlook.com recolours an element in dark mode, it stores the original value in an attribute: &lt;code&gt;data-ogsc&lt;/code&gt; for a changed CSS text colour and &lt;code&gt;data-ogsb&lt;/code&gt; for a changed CSS background (plus &lt;code&gt;data-ogac&lt;/code&gt; and &lt;code&gt;data-ogab&lt;/code&gt; for HTML colour attributes). caniemail notes the same attributes in the Outlook apps. Because they only appear in dark mode, email developers use them as selectors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;data-ogsc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="nc"&gt;.email-text&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#e6e6e6&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;data-ogsb&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="nc"&gt;.email-card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#1e1e1e&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These rules only match inside a parent Outlook has already recoloured, so they rely on an outer wrapper with a light background and dark text. Treat this as a hack: Microsoft doesn't document it, caniemail last recorded it in 2023 and Litmus rates support as partial. Use it only to fine-tune Outlook, never for anything the email depends on.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to design colours and images that survive inversion
&lt;/h2&gt;

&lt;p&gt;In the Gmail apps and classic Outlook you can't send dark styles, so the design itself has to cope:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Keep text as live HTML text.&lt;/strong&gt; Clients recolour HTML text and backgrounds, but the pixels inside an image stay the same. A headline baked into a white image becomes a bright rectangle on a dark screen.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch transparent PNGs.&lt;/strong&gt; Dark artwork on a transparent background can vanish once the background turns dark. Give it a subtle light outline or glow, or place it on a solid shape inside the image. Logos are the usual casualty, and I've covered the Gmail logo fixes in a separate article.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Choose mid-tone brand colours.&lt;/strong&gt; Very light tints often get darkened, and very dark ones may be lightened. A colour that reads well on both white and black survives best.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use strong button colours.&lt;/strong&gt; Partial inversion tends to keep dark button backgrounds. A strong button colour with white text usually comes through intact.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check thin lines and borders.&lt;/strong&gt; Light grey dividers can disappear or turn harsh after inversion.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When I write dark styles, I use a dark grey such as &lt;code&gt;#121212&lt;/code&gt; instead of pure black and an off-white for text, which is easier on the eyes. I make these decisions while coding every &lt;a href="https://keshurgojiya.com/services/html-email-templates" rel="noopener noreferrer"&gt;HTML email template&lt;/a&gt;, because dark mode is far easier to plan into a design than to patch after launch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dark mode email accessibility: contrast in both modes
&lt;/h2&gt;

&lt;p&gt;Accessibility in dark mode means checking contrast twice. WCAG asks for a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text (18pt, or 14pt bold). Check your light palette and your dark palette separately.&lt;/p&gt;

&lt;p&gt;Good contrast also means fewer surprises: Outlook.com has been documented recolouring text whose contrast against its dark background falls below 4.5:1.&lt;/p&gt;

&lt;p&gt;Links need attention too. A standard blue link that passes on white can fail on a dark background, so give links a lighter colour in your dark styles and underline them so they never rely on colour alone. Finally, think before you force light mode: people often choose dark mode for comfort or light sensitivity.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to preview and test dark mode emails
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Check the code first.&lt;/strong&gt; The &lt;a href="https://keshurgojiya.com/tools/html-email-checker" rel="noopener noreferrer"&gt;HTML email checker&lt;/a&gt; flags code-level basics before any send, such as dark styles without the &lt;code&gt;color-scheme&lt;/code&gt; meta tag, images without alt text and layout tables missing &lt;code&gt;role="presentation"&lt;/code&gt;. It checks the code only, not how inboxes render it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test on real devices.&lt;/strong&gt; Switch an iPhone or Mac to dark appearance and open the email in Apple Mail. Set the Gmail app's theme to dark on iOS and Android, since the two invert differently.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test Outlook.&lt;/strong&gt; Turn on dark mode in Outlook.com and switch classic Outlook to the Black Office theme.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use a testing platform&lt;/strong&gt; such as Litmus or Email on Acid for dark mode previews across clients you don't own.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Skip Gmail's web theme for this: it keeps email bodies light. In each client, check the logo, buttons, dividers, text over images and footer links.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can I stop Gmail from changing my email colours in dark mode?
&lt;/h3&gt;

&lt;p&gt;In the Gmail apps, Google documents &lt;code&gt;&amp;lt;meta name="color-scheme" content="light only"&amp;gt;&lt;/code&gt; for Google accounts, which keeps your email in light colours. Gmail on the web already shows email bodies on a light background. You can't send custom dark styles to Gmail at all.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does Outlook support dark mode in HTML email?
&lt;/h3&gt;

&lt;p&gt;Partly. Outlook.com and the Outlook apps for Mac, iOS and Android support &lt;code&gt;prefers-color-scheme&lt;/code&gt; according to caniemail, though results vary. Classic Outlook for Windows ignores it and inverts colours itself, so the design has to survive that.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I make an email signature work in dark mode?
&lt;/h3&gt;

&lt;p&gt;You can't add dark mode CSS to a signature: Gmail, for example, removes &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; blocks from HTML pasted into it, so signatures rely on inline styles. Use live text instead of images of text and a logo that works on dark backgrounds, such as a transparent PNG with a light outline.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need a separate dark version of my email?
&lt;/h3&gt;

&lt;p&gt;No. You send one email with light styles inline and optional dark styles in a media query. Clients that support dark mode CSS use your dark styles, and the rest apply their own inversion.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Email clients either leave colours alone, invert them partly or invert them fully.&lt;/li&gt;
&lt;li&gt;Dark mode CSS works mainly in Apple Mail and Outlook.com; Gmail ignores it.&lt;/li&gt;
&lt;li&gt;Design so the email survives inversion: live text, mid-tone colours, logos with outlines.&lt;/li&gt;
&lt;li&gt;Check contrast in both modes and test on real devices, not Gmail's web theme.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This article was first published on &lt;a href="https://keshurgojiya.com/blog/dark-mode-html-email-guide" rel="noopener noreferrer"&gt;keshurgojiya.com&lt;/a&gt;. I'm Keshur Gojiya, a web developer and HTML email specialist. More guides and free email tools: &lt;a href="https://keshurgojiya.com/tools" rel="noopener noreferrer"&gt;keshurgojiya.com/tools&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>email</category>
      <category>darkmode</category>
    </item>
    <item>
      <title>How to Create an HTML Email Signature (With Code)</title>
      <dc:creator>Keshur Gojiya</dc:creator>
      <pubDate>Sun, 06 Dec 2026 06:01:39 +0000</pubDate>
      <link>https://dev.to/keshurgojiya/how-to-create-an-html-email-signature-with-code-4a3k</link>
      <guid>https://dev.to/keshurgojiya/how-to-create-an-html-email-signature-with-code-4a3k</guid>
      <description>&lt;p&gt;To create an HTML email signature, build it as a small HTML table with inline styles, link every image from an https address with width, height and alt attributes, and keep the code well under Gmail's 10,000-character signature limit. Then open the file in a browser, copy the rendered signature and paste it into your email app's signature settings, because most email apps have no box for raw HTML. The steps and complete, copyable code are below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Plan the content and layout
&lt;/h2&gt;

&lt;p&gt;Decide what goes in before writing any code: name, job title and company, one phone number, email and website, a logo or headshot, and two or three social icons for profiles you keep up to date. Banners, booking links and legal text are optional.&lt;/p&gt;

&lt;p&gt;The most dependable layout is an image on the left and the details on the right, which is what the code below uses. Keep the whole signature about 300 to 500 pixels wide, so it fits on a phone screen and in a narrow reading pane.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Build the layout with tables, not divs
&lt;/h2&gt;

&lt;p&gt;Classic Outlook for Windows uses Microsoft Word to display email, and caniemail.com lists flexbox and CSS grid as unsupported in every Outlook for Windows version it tested. Tables work everywhere:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;&amp;lt;table&amp;gt;&lt;/code&gt; with &lt;code&gt;cellpadding="0" cellspacing="0" border="0"&lt;/code&gt; to remove the default spacing.&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;role="presentation"&lt;/code&gt; so screen readers don't announce it as a data table.&lt;/li&gt;
&lt;li&gt;Make columns with &lt;code&gt;&amp;lt;td&amp;gt;&lt;/code&gt; cells, and nest a second table for the lines of details.&lt;/li&gt;
&lt;li&gt;Create space with &lt;code&gt;padding&lt;/code&gt; on &lt;code&gt;&amp;lt;td&amp;gt;&lt;/code&gt; cells rather than &lt;code&gt;margin&lt;/code&gt;, which Outlook handles less predictably.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 3: Put every style inline
&lt;/h2&gt;

&lt;p&gt;Inline styles are the only kind you can rely on in a signature. A &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; block sits in the file's head, outside the part you copy and paste, and support for style blocks varies between email apps anyway. Put fonts, colours, sizes, padding and borders in a &lt;code&gt;style&lt;/code&gt; attribute on each element.&lt;/p&gt;

&lt;p&gt;Skip CSS that classic Outlook for Windows ignores. It doesn't support &lt;code&gt;border-radius&lt;/code&gt;, so a round headshot should be cropped into a circle in the image file itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Host images online and size them properly
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Upload images to your website&lt;/strong&gt; and link them with full https addresses, such as &lt;code&gt;https://yourcompany.com/signature/logo.png&lt;/code&gt;. A local path like &lt;code&gt;images/logo.png&lt;/code&gt; breaks as soon as the email leaves your computer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Export at 2x, display at 1x.&lt;/strong&gt; A headshot shown at 80 × 80 pixels should be a 160 × 160 pixel file, so it stays sharp on high-density screens.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; attributes&lt;/strong&gt; to the display size, and repeat them in the inline style. Classic Outlook for Windows ignores CSS width on images, so without the attributes a 2x image shows at double size there.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write alt text&lt;/strong&gt; for every image. Some email apps hold back images until the reader allows them, and the alt text shows instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use PNG or JPG:&lt;/strong&gt; PNG for logos and social icons, JPG for photos. SVG and WebP aren't displayed by every version of Outlook, and images embedded as base64 make the code enormous.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 5: Make phone, email and web links work
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Phone:&lt;/strong&gt; &lt;code&gt;tel:&lt;/code&gt; followed by the full international number without spaces, such as &lt;code&gt;tel:+15555550123&lt;/code&gt;, so it dials with one tap.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Email:&lt;/strong&gt; &lt;code&gt;mailto:&lt;/code&gt; followed by the address.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Website and social profiles:&lt;/strong&gt; full https addresses.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Give each link its colour and &lt;code&gt;text-decoration:none&lt;/code&gt; inline, otherwise many apps show their default blue, underlined link style.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Choose a font stack and text sizes
&lt;/h2&gt;

&lt;p&gt;In caniemail.com's tests, custom web fonts don't load in Gmail or in Outlook for Windows. Use a web-safe stack such as &lt;code&gt;font-family:Arial, Helvetica, sans-serif;&lt;/code&gt; or &lt;code&gt;font-family:Georgia, 'Times New Roman', serif;&lt;/code&gt;. Set sizes in pixels, roughly 15 to 17 px for your name and 12 to 14 px for the rest, with a pixel &lt;code&gt;line-height&lt;/code&gt; on every cell so the spacing stays consistent. If your brand font matters, let the logo image carry it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: Keep it narrow and light
&lt;/h2&gt;

&lt;p&gt;Gmail allows up to 10,000 characters in a signature, and Google notes that images count toward the limit too, so it's the code behind the signature that counts, not only the words you see. Code exported from word processors can hit the limit even when the signature looks short. The complete example below is about 2,400 characters.&lt;/p&gt;

&lt;h2&gt;
  
  
  The complete HTML email signature code
&lt;/h2&gt;

&lt;p&gt;This signature follows every step above. Replace the example.com image addresses with your own hosted files, then change the text and links.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;table&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"presentation"&lt;/span&gt; &lt;span class="na"&gt;cellpadding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;cellspacing&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;border&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"border-collapse:collapse; font-family:Arial, Helvetica, sans-serif;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;valign&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"top"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"padding:0 16px 0 0;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://example.com/signature/alex-morgan.jpg"&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"80"&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"80"&lt;/span&gt; &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Alex Morgan"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"display:block; width:80px; height:80px; border:0;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;valign&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"top"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"padding:0 0 0 16px; border-left:2px solid #0f766e;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;table&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"presentation"&lt;/span&gt; &lt;span class="na"&gt;cellpadding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;cellspacing&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;border&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"border-collapse:collapse;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"padding:0 0 2px 0; font-size:16px; line-height:20px; font-weight:bold; color:#111111;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Alex Morgan&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"padding:0 0 8px 0; font-size:13px; line-height:18px; color:#555555;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Project Manager, Example &lt;span class="ni"&gt;&amp;amp;amp;&lt;/span&gt; Co.&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"font-size:13px; line-height:20px;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"tel:+15555550123"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"color:#333333; text-decoration:none;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;+1 555-555-0123&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"font-size:13px; line-height:20px;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"mailto:alex@example.com"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"color:#333333; text-decoration:none;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;alex@example.com&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"font-size:13px; line-height:20px;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://example.com"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"color:#0f766e; text-decoration:none; font-weight:bold;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;example.com&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"padding:10px 0 0 0;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;table&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"presentation"&lt;/span&gt; &lt;span class="na"&gt;cellpadding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;cellspacing&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;border&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"border-collapse:collapse;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"padding:0 8px 0 0;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                  &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://www.linkedin.com/company/example"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://example.com/signature/linkedin.png"&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"LinkedIn"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"display:block; width:20px; height:20px; border:0;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;
                  &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://www.instagram.com/example"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://example.com/signature/instagram.png"&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Instagram"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"display:block; width:20px; height:20px; border:0;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What each part does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The outer table has two cells: the photo, and the details with a 2 px brand-coloured left border as the divider.&lt;/li&gt;
&lt;li&gt;The details sit in a nested table, one row per line, so spacing stays even across email apps.&lt;/li&gt;
&lt;li&gt;Every image has &lt;code&gt;width&lt;/code&gt;, &lt;code&gt;height&lt;/code&gt; and &lt;code&gt;alt&lt;/code&gt; attributes, plus &lt;code&gt;display:block&lt;/code&gt; to remove the small gap some apps add below images. The photo file is 160 × 160 pixels and the icons 40 × 40, all shown at half size.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 8: Test before you install
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open the file in a browser and check that every image loads from its https address.&lt;/li&gt;
&lt;li&gt;Install it in your own account (step 9), then send test emails to a Gmail address, an Outlook address and, if you can, an iPhone.&lt;/li&gt;
&lt;li&gt;Check it on a phone, in dark mode and inside a reply, and tap every link.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When I build &lt;a href="https://keshurgojiya.com/services/html-email-signatures" rel="noopener noreferrer"&gt;HTML email signatures&lt;/a&gt; for clients, classic Outlook for Windows is where most problems show up, usually extra spacing or an image at the wrong size.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 9: Install it by copying the rendered signature
&lt;/h2&gt;

&lt;p&gt;Most email apps don't accept raw HTML code in their signature settings. Keep only the signature in the file, open it in a browser, press Ctrl+A (Cmd+A on a Mac) to select it, copy, and paste it into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gmail:&lt;/strong&gt; Settings &amp;gt; See all settings &amp;gt; General &amp;gt; Signature, then Save Changes at the bottom of the page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;New Outlook and Outlook on the web:&lt;/strong&gt; Settings &amp;gt; Accounts &amp;gt; Signatures.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Classic Outlook for Windows:&lt;/strong&gt; File &amp;gt; Options &amp;gt; Mail &amp;gt; Signatures.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apple Mail on a Mac:&lt;/strong&gt; Mail &amp;gt; Settings &amp;gt; Signatures, then untick "Always match my default message font".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;iPhone Mail:&lt;/strong&gt; Apple says you can only use text in Mail signatures, so a formatted signature there is a workaround, not a supported feature.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each app has its own quirks, which I cover in separate guides.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How do I change my signature in Gmail using HTML code?
&lt;/h3&gt;

&lt;p&gt;Gmail's signature box has no HTML view, so pasted code shows up as plain text tags. Open your HTML file in a browser, copy the rendered signature and paste it into the Signature section of Gmail's settings, with every image on an https address.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is an HTML email signature generator good enough?
&lt;/h3&gt;

&lt;p&gt;It can be a quick start for a simple signature. Check that the code is table-based with inline styles, that it looks right in Outlook, and where the images are hosted: if they stay on the generator's server, your signature depends on that service.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I edit an HTML email signature later?
&lt;/h3&gt;

&lt;p&gt;Edit the HTML file in a code editor, check it in a browser, then copy and paste it into your email app again, because each app stores its own copy. Without touching code, the free &lt;a href="https://keshurgojiya.com/editor" rel="noopener noreferrer"&gt;signature editor&lt;/a&gt; changes an existing signature's text, images and links and copies the result, ready to paste.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Build the signature as a table with inline styles; avoid div layouts, flexbox, grid and style blocks.&lt;/li&gt;
&lt;li&gt;Host images at https addresses, export them at 2x, and set width, height and alt attributes.&lt;/li&gt;
&lt;li&gt;Use tel: and mailto: links, a web-safe font stack, and stay well under Gmail's 10,000-character limit.&lt;/li&gt;
&lt;li&gt;Install it by copying the rendered signature from a browser, not by pasting the code.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This article was first published on &lt;a href="https://keshurgojiya.com/blog/code-html-email-signature-from-scratch" rel="noopener noreferrer"&gt;keshurgojiya.com&lt;/a&gt;. I'm Keshur Gojiya, a web developer and HTML email specialist. More guides and free email tools: &lt;a href="https://keshurgojiya.com/tools" rel="noopener noreferrer"&gt;keshurgojiya.com/tools&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>email</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>CSS Support in Email Clients: What Works Where</title>
      <dc:creator>Keshur Gojiya</dc:creator>
      <pubDate>Sun, 06 Dec 2026 06:01:11 +0000</pubDate>
      <link>https://dev.to/keshurgojiya/css-support-in-email-clients-what-works-where-196f</link>
      <guid>https://dev.to/keshurgojiya/css-support-in-email-clients-what-works-where-196f</guid>
      <description>&lt;p&gt;CSS support in email clients is much narrower than in browsers, and it differs from client to client. Apple Mail supports nearly all modern CSS, Gmail accepts a documented subset and strips the rest, and classic Outlook for Windows renders email with Microsoft Word and ignores much of it. The approach that holds up everywhere is tables for layout, inline styles for anything the email needs, and a &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; block only for extras such as mobile tweaks and dark mode.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why does CSS work differently in email?
&lt;/h2&gt;

&lt;p&gt;An email client isn't a browser. It shows HTML from strangers inside its own interface, so it removes anything that could break out of the message area or track the reader: positioning, scripts, external files. It also rewrites class names and adds its own styles. Each vendor decides what to allow, nobody follows a shared standard, and you can't use JavaScript to detect the client and adapt.&lt;/p&gt;

&lt;p&gt;So writing CSS for email means asking "what does each client keep?" rather than "what does CSS support?".&lt;/p&gt;

&lt;h2&gt;
  
  
  Inline styles or a style block: which clients support what?
&lt;/h2&gt;

&lt;p&gt;Most clients read a &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; block in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;: Apple Mail, Outlook.com, the Outlook apps for Mac, iOS and Android, Yahoo Mail, Samsung Email and classic Outlook for Windows. The exceptions matter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gmail&lt;/strong&gt; (web, Android and iOS with a Google account) reads &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; only inside the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; and removes blocks placed in the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Gmail app with a non-Google account&lt;/strong&gt; (Outlook, Yahoo or any IMAP, POP or Exchange account added to the app) removes &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; blocks and media queries completely. Only inline &lt;code&gt;style&lt;/code&gt; attributes survive.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Media query support is patchier still. Apple Mail supports them fully. Gmail supports &lt;code&gt;screen&lt;/code&gt; and &lt;code&gt;all&lt;/code&gt; queries on &lt;code&gt;width&lt;/code&gt;, &lt;code&gt;device-width&lt;/code&gt;, &lt;code&gt;orientation&lt;/code&gt; and &lt;code&gt;resolution&lt;/code&gt;, nothing else. Outlook.com and the Outlook mobile apps support them but not nested queries. Classic Outlook for Windows ignores media queries entirely.&lt;/p&gt;

&lt;p&gt;My rule on every build: anything the email needs to be readable (fonts, colours, widths, padding) goes inline, and the &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; block only holds enhancements. I write the CSS in a style block while building, then inline it before sending. A &lt;a href="https://keshurgojiya.com/tools/css-inliner-for-email" rel="noopener noreferrer"&gt;CSS inliner for email&lt;/a&gt; does that and keeps your media queries in the head.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gmail CSS not working? The usual causes
&lt;/h2&gt;

&lt;p&gt;When Gmail ignores your CSS, the cause is almost always one of these:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The style block is in the body.&lt;/strong&gt; This usually happens when CSS is pasted into a content block in an email builder. Move it into the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One syntax error.&lt;/strong&gt; A missing brace or semicolon makes Gmail discard the entire &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; block, not just the broken rule.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Modern syntax Gmail can't parse.&lt;/strong&gt; &lt;code&gt;:is()&lt;/code&gt;, &lt;code&gt;:where()&lt;/code&gt;, range media queries like &lt;code&gt;(width &amp;gt;= 500px)&lt;/code&gt;, and space-separated colours like &lt;code&gt;rgb(0 0 0 / 50%)&lt;/code&gt;, &lt;code&gt;oklch()&lt;/code&gt; or &lt;code&gt;color-mix()&lt;/code&gt; also discard the whole block. Inline, a space-separated colour removes the element's entire &lt;code&gt;style&lt;/code&gt; attribute. Use &lt;code&gt;rgb(0, 0, 0)&lt;/code&gt; and &lt;code&gt;(max-width: 600px)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Too much CSS.&lt;/strong&gt; All &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; blocks together can't exceed 16,384 characters. The block that crosses the limit, and every block after it, is dropped.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unsupported properties.&lt;/strong&gt; Gmail removes them one by one: &lt;code&gt;position&lt;/code&gt;, &lt;code&gt;z-index&lt;/code&gt;, &lt;code&gt;flex&lt;/code&gt;, &lt;code&gt;justify-content&lt;/code&gt;, &lt;code&gt;gap&lt;/code&gt;, &lt;code&gt;box-shadow&lt;/code&gt;, &lt;code&gt;transform&lt;/code&gt; and custom properties, plus negative margins.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unsupported selectors.&lt;/strong&gt; Only &lt;code&gt;:hover&lt;/code&gt; survives among pseudo-classes (and not on iOS), only &lt;code&gt;[class~="value"]&lt;/code&gt; among attribute selectors, and pseudo-elements like &lt;code&gt;::before&lt;/code&gt; are removed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The reader's account isn't a Google account.&lt;/strong&gt; In the Gmail app, that means inline styles only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The email was pasted, forwarded or printed.&lt;/strong&gt; Pasting HTML into Gmail's compose window removes the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt;. Replies, forwards, printing and "View entire message" on a clipped email keep only inline styles.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Google documents all of this on its Gmail CSS support page at developers.google.com, which is worth bookmarking.&lt;/p&gt;

&lt;h2&gt;
  
  
  Outlook CSS support: classic Outlook vs the rest
&lt;/h2&gt;

&lt;p&gt;"Outlook" covers very different engines. Outlook.com, the new Outlook for Windows (which renders much like Outlook.com) and the Outlook apps for Mac, iOS and Android handle style blocks, media queries and even flexbox.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Classic Outlook for Windows&lt;/strong&gt; uses Word's engine, and its limits shape every email layout:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;max-width&lt;/code&gt; is ignored (newer versions apply it to tables only), so widths go in &lt;code&gt;width&lt;/code&gt; attributes.&lt;/li&gt;
&lt;li&gt;Padding is reliable only on table cells, and margins are partial (&lt;code&gt;auto&lt;/code&gt; doesn't work).&lt;/li&gt;
&lt;li&gt;No &lt;code&gt;border-radius&lt;/code&gt;, &lt;code&gt;float&lt;/code&gt;, &lt;code&gt;rem&lt;/code&gt; units or media queries.&lt;/li&gt;
&lt;li&gt;CSS background images and gradients need VML.&lt;/li&gt;
&lt;li&gt;Font weights below 600 render as normal and 600 or above as bold.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I cover the Word-engine fixes themselves (ghost tables, line-height, VML buttons) in my guide to Outlook rendering, so I won't repeat them here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which CSS properties should you avoid in email?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Flexbox and grid.&lt;/strong&gt; Gmail keeps &lt;code&gt;display&lt;/code&gt; but strips &lt;code&gt;flex&lt;/code&gt;, &lt;code&gt;grid&lt;/code&gt;, &lt;code&gt;justify-content&lt;/code&gt;, &lt;code&gt;align-items&lt;/code&gt; and &lt;code&gt;gap&lt;/code&gt;, so the layout falls apart. Classic Outlook ignores them. Use tables for columns.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;position, top, left, z-index.&lt;/strong&gt; Removed by Gmail and ignored by classic Outlook. Overlapping layouts need a different design.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;float.&lt;/strong&gt; Ignored by classic Outlook. Use the &lt;code&gt;align&lt;/code&gt; attribute on a table or image instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CSS variables.&lt;/strong&gt; Not supported in Gmail, Outlook.com or classic Outlook. Write literal values.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;box-shadow.&lt;/strong&gt; Not in Gmail on the web or classic Outlook. Treat it as decoration you can lose.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Background gradients.&lt;/strong&gt; caniemail lists &lt;code&gt;linear-gradient()&lt;/code&gt; as working in Gmail, Apple Mail and Samsung Email, but not in classic Outlook, Outlook.com, the Outlook apps or Yahoo Mail. Always set a solid colour first.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is the gradient pattern I use. The &lt;code&gt;bgcolor&lt;/code&gt; attribute and &lt;code&gt;background-color&lt;/code&gt; give every client a solid colour, and clients that understand the gradient paint it on top:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;bgcolor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#1d4ed8"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"background-color: #1d4ed8; background: linear-gradient(90deg, #1d4ed8, #7c3aed); padding: 32px; color: #ffffff; font-family: Arial, sans-serif;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  The new collection is live
&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I use the &lt;code&gt;background&lt;/code&gt; shorthand rather than &lt;code&gt;background-image&lt;/code&gt; on purpose: Gmail for Android has a known bug that breaks gradients written inline in &lt;code&gt;background-image&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What CSS is safe in almost every email client?
&lt;/h2&gt;

&lt;p&gt;This set works in all the major clients, classic Outlook included:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tables with &lt;code&gt;width&lt;/code&gt;, &lt;code&gt;cellpadding&lt;/code&gt;, &lt;code&gt;cellspacing&lt;/code&gt; and &lt;code&gt;align&lt;/code&gt; attributes&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;background-color&lt;/code&gt; (backed by &lt;code&gt;bgcolor&lt;/code&gt;) and &lt;code&gt;color&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;font-family&lt;/code&gt;, &lt;code&gt;font-size&lt;/code&gt; and &lt;code&gt;line-height&lt;/code&gt; in pixels (classic Outlook needs &lt;code&gt;mso-line-height-rule: exactly&lt;/code&gt; to honour line-height precisely)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;font-weight&lt;/code&gt; as normal or bold&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;text-align&lt;/code&gt; and &lt;code&gt;text-decoration&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;padding&lt;/code&gt; and &lt;code&gt;border&lt;/code&gt; on table cells (classic Outlook caps borders at 8px)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;border-radius&lt;/code&gt;, which simply shows square corners in classic Outlook&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Build the email from these, then add everything else as progressive enhancement that can fail without breaking the message.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to check CSS support before you send
&lt;/h2&gt;

&lt;p&gt;Look the property up on caniemail.com. Each feature page lists support per client and version, and the numbered notes hold the real detail, such as "not supported with non Google accounts". Check the test date too: some entries are years old.&lt;/p&gt;

&lt;p&gt;Then send real tests to the inboxes your audience uses, including the Gmail app with a non-Google account and classic Outlook. This cross-client checking is part of every &lt;a href="https://keshurgojiya.com/services/html-email-templates" rel="noopener noreferrer"&gt;HTML email template&lt;/a&gt; I code, because a property that works in one inbox tells you nothing about the next.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does Gmail support CSS in the head?
&lt;/h3&gt;

&lt;p&gt;Yes. Gmail on the web, Android and iOS reads &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; blocks in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; for Google accounts, within its limits on size, syntax and supported properties. The Gmail app removes them when the account is not a Google account, so essential styles must be inline.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does Outlook support media queries?
&lt;/h3&gt;

&lt;p&gt;Outlook.com, the new Outlook for Windows and the Outlook apps for Mac, iOS and Android support them, except nested queries. Classic Outlook for Windows ignores them, so the desktop layout has to work at a fixed width without any media query.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I use flexbox in HTML email?
&lt;/h3&gt;

&lt;p&gt;Only as an enhancement. Apple Mail and Outlook.com handle it, but Gmail strips the flex properties and classic Outlook ignores them. Tables remain the reliable way to build columns.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is linear-gradient supported in email clients?
&lt;/h3&gt;

&lt;p&gt;Partly. It works in Gmail, Apple Mail and Samsung Email, but not in classic Outlook, Outlook.com, the Outlook apps or Yahoo Mail. Put a solid &lt;code&gt;background-color&lt;/code&gt; before the gradient so those clients still show a colour.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Inline every style the email needs; keep the &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; block for enhancements only.&lt;/li&gt;
&lt;li&gt;Gmail drops a whole style block on one syntax error, modern syntax or more than 16,384 characters.&lt;/li&gt;
&lt;li&gt;Classic Outlook for Windows ignores max-width, border-radius, float, gradients and media queries.&lt;/li&gt;
&lt;li&gt;Check each property on caniemail.com and give every modern effect a fallback.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This article was first published on &lt;a href="https://keshurgojiya.com/blog/css-support-email-clients" rel="noopener noreferrer"&gt;keshurgojiya.com&lt;/a&gt;. I'm Keshur Gojiya, a web developer and HTML email specialist. More guides and free email tools: &lt;a href="https://keshurgojiya.com/tools" rel="noopener noreferrer"&gt;keshurgojiya.com/tools&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>email</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
