{"id":15588,"date":"2014-01-21T14:40:00","date_gmt":"2014-01-21T14:40:00","guid":{"rendered":"https:\/\/www.litmus.com\/?p=15588"},"modified":"2025-11-05T13:39:11","modified_gmt":"2025-11-05T18:39:11","slug":"understanding-gmail-and-css-part-1","status":"publish","type":"post","link":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1","title":{"rendered":"Understanding Gmail and CSS"},"content":{"rendered":"<div class=\"update\">\n<p><strong>Update (09\/2016)<\/strong><br \/>\nThings have changed since we wrote this post. Gmail rolled out support for responsive design, improved font styling, and CSS for accessibility. Now, Gmail supports embedded CSS, which removes the need for inline CSS in Gmail.<\/p>\n<p><a rel=\"noopener\" href=\"https:\/\/litmus.com\/blog\/gmail-to-support-responsive-email-design\/\">Learn more \u2192<\/a><\/p>\n<\/div>\n<p dir=\"ltr\">Google\u2019s free Gmail service is one of the most popular email services in the world. Marketers and designers frequently find their campaigns breaking in this popular email client, and struggle with how to make their campaigns render consistently. While 80% of Gmail users opt to access their accounts via mobile and desktop email clients, the remaining 20% open emails in the webmail interface, which offers less than stellar support for CSS (Cascading Style Sheets).<\/p>\n<p>Let\u2019s take a look at an overview of CSS support in Gmail and options for styling emails with CSS.<\/p>\n<h2 dir=\"ltr\">Styling Email<\/h2>\n<p dir=\"ltr\">CSS, or Cascading Style Sheets, are used to add styles and formatting to HTML pages\u2014yes, and emails, too! There are three ways to include styles within an email: using external stylesheets, embedded styles, or inline styles.<\/p>\n<h3 dir=\"ltr\">External Stylesheets<\/h3>\n<p dir=\"ltr\">Web designers will be familiar with external stylesheets, which use a link to load a stylesheet from a server.\u00a0They\u2019re particularly useful for multi-page sites, where headlines, body copy, link colors, and other formatting options can be controlled by changing a single file rather than individual styles on each page:<\/p>\n<pre><code>&lt;link rel=\"stylesheet\" rel=\"noopener\" target=\"_blank\" href=\"\/path\/to\/style.css\" \/&gt;<\/code><\/pre>\n<p dir=\"ltr\">Since most webmail clients block links to external stylesheets and Javascript, it is rare to see this method employed in an email.<\/p>\n<h3 dir=\"ltr\">Embedded Styles<\/h3>\n<p dir=\"ltr\">Embedded styles are a bit similar to external styles in that broad categories of formatting options for the entire page (or email) are controlled in a single place. CSS rules that are embedded are declared in a <em>&lt;style&gt;<\/em> block in an HTML document, normally in the &lt;<em>head&gt;<\/em> section:<\/p>\n<pre><code>&lt;html&gt;\n &lt;head&gt;\n &lt;meta charset=utf-8&gt;\n &lt;style type=\"text\/css\"&gt;\n .ReadMsgBody {width: 100%;}\n .ExternalClass {width: 100%;}\n &lt;\/style&gt;\n &lt;\/head&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<p dir=\"ltr\">Embedded styles are useful when you frequently re-use the same style in an email: for example, they can help you avoid declaring the same font color for links over and over. However, embedded styles are not always supported in email\u2014leading to rendering inconsistencies between email clients.<\/p>\n<p dir=\"ltr\">That said, using embedded styles in email has become more popular\u2014and a more accepted practice\u2014due to the rise of mobile and associated popularity of <a rel=\"noopener\" href=\"https:\/\/litmus.com\/blog\/the-how-to-guide-to-responsive-email-design-infographic\">responsive design techniques<\/a>.<\/p>\n<h3 dir=\"ltr\">Inline Styles<\/h3>\n<p dir=\"ltr\">Inline styles are applied directly to HTML elements in each line of HTML (hence the clever name, <em>in line<\/em>), like so:<\/p>\n<pre><code>&lt;span style=\"font-size: 22px; font-family: Arial, sans-serif; color: #222222;\" &gt;Hello!&lt;\/span&gt;<\/code><\/pre>\n<p dir=\"ltr\">Inline styles are generally the safest way to ensure rendering compatibility across various email clients, programs and devices, but can be time-consuming to write and a bit challenging to manage.<\/p>\n<h3 dir=\"ltr\">When should I use each type of CSS?<\/h3>\n<p dir=\"ltr\">Most email designers use a mix of inline and embedded styles when building email campaigns, as they can serve different purposes. The main structure and styling of your email should be kept inline, as that is the most reliable way to get your email rendering across clients. Embedded styles are normally used when utilizing a CSS \u201c<a rel=\"noopener\" target=\"_blank\" href=\"http:\/\/templates.mailchimp.com\/development\/css\/reset-styles\">reset<\/a>\u201d or for CSS rules used in responsive emails.<\/p>\n<p dir=\"ltr\">Understanding the structure of an HTML document, how CSS is used by email designers, and how Gmail handles both is the key to understanding rendering issues in Gmail.<\/p>\n<h2 dir=\"ltr\">Gmail&#8217;s Rocky Relationship with CSS<\/h2>\n<p dir=\"ltr\">As a webmail client, Gmail has to take some precautions when displaying an email. Like most webmail clients, Gmail uses a preprocessor to strip any code from an email that could be a security threat or interfere with the rendering of the client interface itself.<\/p>\n<p dir=\"ltr\">Commonly stripped elements include JavaScript, object and embed tags, and Flash. Gmail goes one step further and strips out both the head and body tags, as well as any style tags in an email.<\/p>\n<p dir=\"ltr\">Once an email is run through the preprocessor, it is passed to the app and rendered by the browser. While different browsers can have their own rendering quirks, most issues that designers run into stem from styles that were stripped by Google\u2019s preprocessing.<\/p>\n<h2 dir=\"ltr\">Solid Styling for Gmail<\/h2>\n<p dir=\"ltr\">The quickest way to insure your email campaign renders properly in Gmail is to place your most important styles inline.<\/p>\n<p dir=\"ltr\">A lot of designers, especially those coming from a web-heavy background, prefer to develop emails with CSS in the head of the email. The development process can definitely be quicker using this method, but care should be taken to move styles inline before deploying an email.<\/p>\n<p dir=\"ltr\">\u201cInlining\u201d styles moves the CSS and associated formatting instructions from the style block in the <em>&lt;head&gt;<\/em> of your email into the body of the HTML. An inlining tool will look at the styles, classes and ids declared for each element, find those elements in the body, and move the styles accordingly:<\/p>\n<pre><code>td[class=\"copy\"] { \n font-size: 18px;\n font-family: Arial, sans-serif;\n color: #222222;\n}<\/code><\/pre>\n<p dir=\"ltr\">The end result is something like this:<\/p>\n<pre><code>&lt;td style=\"font-size: 18px; font-family: Arial, sans-serif; color: #222222;\" &gt;Bonjour!&lt;\/td&gt;<\/code><\/pre>\n<p dir=\"ltr\">There are a variety of tools for inlining CSS, including our very own <a rel=\"noopener\" target=\"_blank\" href=\"https:\/\/putsmail.com\/inliner\">free CSS inliner<\/a>. If your emails are generated in the back end of an application, solutions exist for most server side languages and frameworks. Popular options include inliners for <a rel=\"noopener\" target=\"_blank\" href=\"https:\/\/github.com\/tijsverkoyen\/CssToInlineStyles\">PHP<\/a>, <a rel=\"noopener\" target=\"_blank\" href=\"https:\/\/www.ruby-toolbox.com\/projects\/premailer\">Ruby<\/a>, <a rel=\"noopener\" target=\"_blank\" href=\"https:\/\/github.com\/SLaks\/Styliner\">Node.js<\/a>, and <a rel=\"noopener\" target=\"_blank\" href=\"https:\/\/github.com\/milkshakesoftware\/PreMailer.Net\">C#<\/a>.<\/p>\n<h2 dir=\"ltr\">What about responsive styles?<\/h2>\n<p dir=\"ltr\"><a rel=\"noopener\" href=\"https:\/\/www.litmus.com\/blog\/a-guide-to-css-inlining-in-email\/\">Inlining CSS<\/a> is great for the general look and feel of an email. But what about handling responsive emails that rely on CSS <a rel=\"noopener\" href=\"https:\/\/www.litmus.com\/blog\/understanding-media-queries-in-html-email\/\">media queries<\/a>?<\/p>\n<p dir=\"ltr\">The answer is to keep those styles within the head of your email. Yes, Gmail will strip them out when it runs your email through a preprocessor, but that\u2019s OK. Ideally, all of the structure and styling in an email is inline. Anything in a media query is an enhancement on top of that styling. Even if it is stripped in webmail clients\u2014<em>it doesn\u2019t matter<\/em>. The styles in the media query aren\u2019t intended to be viewed in a webmail interface\u2014they\u2019re intended for a smartphone or tablet.<\/p>\n<p dir=\"ltr\">In most cases, mobile clients that rely on those media queries and responsive styles will still see and render them properly, but if they are missing in webmail clients, your email will hold up and look great since you took the time to inline your most important styles.<\/p>\n<h2 dir=\"ltr\">Always Test Campaigns<\/h2>\n<p dir=\"ltr\">Gmail can be a tricky client for designers. Understanding how Gmail processes your HTML before and after it hits the inbox is the key to building robust campaigns that display properly. While it\u2019s usually the least, Gmail is still a popular client that needs to be addressed.<\/p>\n<p dir=\"ltr\">Fortunately, Litmus makes <a rel=\"noopener\" href=\"https:\/\/litmus.com\/email-testing\">testing in Gmail<\/a> a breeze. Sign up free today!<\/p>\n<p><a class=\"btn medium orange\" style=\"color: #fff; font-size: 16px; font-weight: bold;\" rel=\"noopener\" href=\"https:\/\/www.litmus.com\/pricing\">Start testing \u2192<\/a><\/p>\n<p dir=\"ltr\">Know of any other tips for dealing with Gmail? Let us know!<\/p>\n<h2 dir=\"ltr\">Additional Resources<\/h2>\n<ul>\n<li><a rel=\"noopener\" target=\"_blank\" href=\"http:\/\/www.campaignmonitor.com\/css\/\">The Ultimate Guide to CSS<\/a> &#8211; Campaign Monitor<\/li>\n<li><a rel=\"noopener\" target=\"_blank\" href=\"http:\/\/templates.mailchimp.com\/resources\/email-client-css-support\">Email Client CSS Support<\/a> &#8211; MailChimp<\/li>\n<\/ul>\n<p><iframe style=\"border: 0;\" src=\"https:\/\/pages.litmus.com\/l\/31032\/2014-10-22\/jl2rh\" width=\"1\" height=\"1\" frameborder=\"0\"><\/iframe><br \/>\n<script src=\"\/\/platform.twitter.com\/oct.js\" type=\"text\/javascript\"><\/script><br \/>\n<script type=\"text\/javascript\"><br \/>\ntwttr.conversion.trackPid('l514s', { tw_sale_amount: 0, tw_order_quantity: 0 });<\/script><br \/>\n<noscript><br \/>\n<img decoding=\"async\" height=\"1\" width=\"1\" style=\"display:none;\" alt=\"\" src=\"https:\/\/www.litmus.com\/wp-content\/uploads\/2020\/05\/img_5ebc06f55fdfb.gif\"><br \/>\n<img decoding=\"async\" height=\"1\" width=\"1\" style=\"display:none;\" alt=\"\" src=\"\/\/t.co\/i\/adsct?txn_id=l514s&amp;p_id=Twitter&amp;tw_sale_amount=0&amp;tw_order_quantity=0\"><\/noscript><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update (09\/2016) Things have changed since we wrote this post. &hellip;<\/p>\n","protected":false},"author":3,"featured_media":15589,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"tags":[],"blog_category":[53],"class_list":["post-15588","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","blog_category-tips-resources"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.5 (Yoast SEO v27.7) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Understanding Gmail and CSS - Litmus<\/title>\n<meta name=\"description\" content=\"Update (09\/2016) Things have changed since we wrote this post. Gmail rolled out support for responsive design, improved font styling, and CSS for\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Understanding Gmail and CSS\" \/>\n<meta property=\"og:description\" content=\"Update (09\/2016) Things have changed since we wrote this post. Gmail rolled out support for responsive design, improved font styling, and CSS for\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1\" \/>\n<meta property=\"og:site_name\" content=\"Litmus\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/litmusapp\" \/>\n<meta property=\"article:published_time\" content=\"2014-01-21T14:40:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-05T18:39:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.litmus.com\/wp-content\/uploads\/2020\/05\/gmail-header1-1000x525-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"525\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@litmusapp\" \/>\n<meta name=\"twitter:site\" content=\"@litmusapp\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Understanding Gmail and CSS - Litmus","description":"Update (09\/2016) Things have changed since we wrote this post. Gmail rolled out support for responsive design, improved font styling, and CSS for","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1","og_locale":"en_US","og_type":"article","og_title":"Understanding Gmail and CSS","og_description":"Update (09\/2016) Things have changed since we wrote this post. Gmail rolled out support for responsive design, improved font styling, and CSS for","og_url":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1","og_site_name":"Litmus","article_publisher":"https:\/\/www.facebook.com\/litmusapp","article_published_time":"2014-01-21T14:40:00+00:00","article_modified_time":"2025-11-05T18:39:11+00:00","og_image":[{"width":1000,"height":525,"url":"https:\/\/www.litmus.com\/wp-content\/uploads\/2020\/05\/gmail-header1-1000x525-1.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_creator":"@litmusapp","twitter_site":"@litmusapp","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1#article","isPartOf":{"@id":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1"},"author":{"name":"","@id":""},"headline":"Understanding Gmail and CSS","datePublished":"2014-01-21T14:40:00+00:00","dateModified":"2025-11-05T18:39:11+00:00","mainEntityOfPage":{"@id":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1"},"wordCount":1103,"commentCount":0,"publisher":{"@id":"https:\/\/www.litmus.com\/#organization"},"image":{"@id":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1#primaryimage"},"thumbnailUrl":"https:\/\/www.litmus.com\/wp-content\/uploads\/2020\/05\/gmail-header1-1000x525-1.png","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1","url":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1","name":"Understanding Gmail and CSS - Litmus","isPartOf":{"@id":"https:\/\/www.litmus.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1#primaryimage"},"image":{"@id":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1#primaryimage"},"thumbnailUrl":"https:\/\/www.litmus.com\/wp-content\/uploads\/2020\/05\/gmail-header1-1000x525-1.png","datePublished":"2014-01-21T14:40:00+00:00","dateModified":"2025-11-05T18:39:11+00:00","description":"Update (09\/2016) Things have changed since we wrote this post. Gmail rolled out support for responsive design, improved font styling, and CSS for","breadcrumb":{"@id":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1#primaryimage","url":"https:\/\/www.litmus.com\/wp-content\/uploads\/2020\/05\/gmail-header1-1000x525-1.png","contentUrl":"https:\/\/www.litmus.com\/wp-content\/uploads\/2020\/05\/gmail-header1-1000x525-1.png","width":1000,"height":525},{"@type":"BreadcrumbList","@id":"https:\/\/www.litmus.com\/blog\/understanding-gmail-and-css-part-1#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.litmus.com\/"},{"@type":"ListItem","position":2,"name":"Understanding Gmail and CSS"}]},{"@type":"WebSite","@id":"https:\/\/www.litmus.com\/#website","url":"https:\/\/www.litmus.com\/","name":"Litmus","description":"Are you getting the most out of your email marketing?","publisher":{"@id":"https:\/\/www.litmus.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.litmus.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.litmus.com\/#organization","name":"Litmus Software","url":"https:\/\/www.litmus.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.litmus.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.litmus.com\/wp-content\/uploads\/2025\/04\/featured-image.png","contentUrl":"https:\/\/www.litmus.com\/wp-content\/uploads\/2025\/04\/featured-image.png","width":600,"height":314,"caption":"Litmus Software"},"image":{"@id":"https:\/\/www.litmus.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/litmusapp","https:\/\/x.com\/litmusapp"]},{"@type":"Person","@id":""}]}},"acf":[],"_links":{"self":[{"href":"https:\/\/www.litmus.com\/wp-json\/wp\/v2\/posts\/15588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.litmus.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.litmus.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.litmus.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.litmus.com\/wp-json\/wp\/v2\/comments?post=15588"}],"version-history":[{"count":3,"href":"https:\/\/www.litmus.com\/wp-json\/wp\/v2\/posts\/15588\/revisions"}],"predecessor-version":[{"id":121053,"href":"https:\/\/www.litmus.com\/wp-json\/wp\/v2\/posts\/15588\/revisions\/121053"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.litmus.com\/wp-json\/wp\/v2\/media\/15589"}],"wp:attachment":[{"href":"https:\/\/www.litmus.com\/wp-json\/wp\/v2\/media?parent=15588"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.litmus.com\/wp-json\/wp\/v2\/tags?post=15588"},{"taxonomy":"blog_category","embeddable":true,"href":"https:\/\/www.litmus.com\/wp-json\/wp\/v2\/blog_category?post=15588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}