{"id":87,"date":"2016-04-30T03:32:44","date_gmt":"2016-04-30T03:32:44","guid":{"rendered":"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/?p=87"},"modified":"2017-05-15T20:58:14","modified_gmt":"2017-05-15T20:58:14","slug":"purple-html-email-hyperlinks","status":"publish","type":"post","link":"https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/purple-html-email-hyperlinks\/","title":{"rendered":"Prevent anchor elements from turning purple after clicking in HTML emails"},"content":{"rendered":"<h2>Prevent HTML email hyperlinks from turning purple after clicking on them<\/h2>\r\n<p>If you test HTML email campaigns using real devices, then this post may be beneficial to you. In Outlook 2010 for example, hyperlinks in their visited state, may turn purple after you click on them, even if you explicitly declare an inline CSS color style in a <span class=\"white_space_pre\">&lt;span&gt;<\/span> element. You wouldn&#8217;t be able to detect this if you are using a email testing software such as Litmus. Here is the initial HTML:<\/p>\r\n<h4>HTML<\/h4>\r\n<pre>\r\n<div class=\"code\">\r\n&lt;table&gt;\r\n &lt;tr&gt;\r\n  &lt;td colspan=&quot;4&quot; color=&quot;#ff6b35&quot;&gt;\r\n   &lt;a style=&quot;color:#ff6b35;text-decoration:none;&quot; href=&quot;#&quot;&gt;Privacy Notice&lt;\/a&gt;\r\n   &lt;a style=&quot;color:#ff6b35;text-decoration:none;&quot; href=&quot;#&quot;&gt;Unsubscribe&lt;\/a&gt;\r\n   &lt;a style=&quot;color:#ff6b35;text-decoration:none;&quot; href=&quot;#&quot;&gt;Terms of Use&lt;\/a&gt;\r\n   &lt;a style=&quot;color:#ff6b35;text-decoration:none;&quot; href=&quot;#&quot;&gt;Legal Notice&lt;\/a&gt;\r\n  &lt;\/td&gt;\r\n &lt;\/tr&gt;\r\n&lt;\/table&gt;\r\n<\/div>\r\n<\/pre>\r\n<p>Here are the hyperlinks in their initial (:linked) state:<\/p>\r\n<img loading=\"lazy\" src=\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-content\/uploads\/2016\/04\/email_anchor_tags_linked-300x20.png\" alt=\"html email hyperlinks linked\" width=\"300\" height=\"20\" class=\"alignnone size-medium wp-image-88\" srcset=\"https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-content\/uploads\/2016\/04\/email_anchor_tags_linked-300x20.png 300w, https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-content\/uploads\/2016\/04\/email_anchor_tags_linked.png 352w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/>\r\n<p>Here are the hyperlinks after clicking on the &#8220;Unsubscribe&#8221; hyperlink (:visited) state &#8211; MS Outlook 2010<\/p>\r\n<img loading=\"lazy\" src=\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-content\/uploads\/2016\/04\/email_anchor_tags_visited-300x20.png\" alt=\"html email hyperlinks visited\" width=\"300\" height=\"20\" class=\"alignnone size-medium wp-image-89\" srcset=\"https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-content\/uploads\/2016\/04\/email_anchor_tags_visited-300x20.png 300w, https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-content\/uploads\/2016\/04\/email_anchor_tags_visited.png 352w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/>\r\n<p>The initial thought may be to surround the text inside the anchor element with a <span class=\"white_space_pre\">&lt;span&gt;<\/span>, and using the same color specified in the anchor element. See the updated HTML below:<\/p>\r\n<h4>HTML<\/h4>\r\n<pre>\r\n<div class=\"code\">\r\n&lt;table&gt;\r\n &lt;tr&gt;\r\n  &lt;td colspan=&quot;4&quot; color=&quot;#ff6b35&quot;&gt;\r\n   &lt;a style=&quot;color:#ff6b35;text-decoration:none;&quot; href=&quot;#&quot;&gt;&lt;span style=&quot;color:#ff6b35;&quot;&gt;Privacy Notice&lt;\/span&gt;&lt;\/a&gt;\r\n   &lt;a style=&quot;color:#ff6b35;text-decoration:none;&quot; href=&quot;#&quot;&gt;&lt;span style=&quot;color:#ff6b35;&quot;&gt;Unsubscribe&lt;\/span&gt;&lt;\/a&gt;\r\n   &lt;a style=&quot;color:#ff6b35;text-decoration:none;&quot; href=&quot;#&quot;&gt;&lt;span style=&quot;color:#ff6b35;&quot;&gt;Terms of Use&lt;\/span&gt;&lt;\/a&gt;\r\n   &lt;a style=&quot;color:#ff6b35;text-decoration:none;&quot; href=&quot;#&quot;&gt;&lt;span style=&quot;color:#ff6b35;&quot;&gt;Legal Notice&lt;\/span&gt;&lt;\/a&gt;\r\n  &lt;\/td&gt;\r\n &lt;\/tr&gt;\r\n&lt;\/table&gt;\r\n<\/div>\r\n<\/pre>\r\n\r\n<p>After testing the email again in Outlook 2010, the links still turn people, despite the code changes above. After experimenting a little bit more, we found our solution. You have to surround the text with a <span class=\"white_space_pre\">&lt;strong&gt;<\/span> element.<\/p>\r\n<h2>Solution<\/h2>\r\n<h4>HTML<\/h4>\r\n<pre>\r\n<div class=\"code\">\r\n&lt;table&gt;\r\n &lt;tr&gt;\r\n  &lt;td colspan=&quot;4&quot; color=&quot;#ff6b35&quot;&gt;\r\n   &lt;a style=&quot;color:#ff6b35;text-decoration:none;&quot; href=&quot;#&quot;&gt;&lt;strong style=&quot;color:#ff6b35;&quot;&gt;Privacy Notice&lt;\/strong&gt;&lt;\/a&gt;\r\n   &lt;a style=&quot;color:#ff6b35;text-decoration:none;&quot; href=&quot;#&quot;&gt;&lt;strong style=&quot;color:#ff6b35;&quot;&gt;Unsubscribe&lt;\/strong&gt;&lt;\/a&gt;\r\n   &lt;a style=&quot;color:#ff6b35;text-decoration:none;&quot; href=&quot;#&quot;&gt;&lt;strong style=&quot;color:#ff6b35;&quot;&gt;Terms of Use&lt;\/strong&gt;&lt;\/a&gt;\r\n   &lt;a style=&quot;color:#ff6b35;text-decoration:none;&quot; href=&quot;#&quot;&gt;&lt;strong style=&quot;color:#ff6b35;&quot;&gt;Legal Notice&lt;\/strong&gt;&lt;\/a&gt;\r\n  &lt;\/td&gt;\r\n &lt;\/tr&gt;\r\n&lt;\/table&gt;\r\n<\/div>\r\n<\/pre>\r\n<p>Using the <span class=\"white_space_pre\">&lt;strong&gt;<\/span> element works, but there is a side effect. The text is now bold. To address this, simply add an inline style of <span class=\"white_space_pre\">style=&#8221;font-weight: normal;&#8221;<\/span> to your <span class=\"white_space_pre\">&lt;strong&gt;<\/span> element and that should do the trick!<\/p>","protected":false},"excerpt":{"rendered":"Prevent HTML email hyperlinks from turning purple after clicking on them If you test HTML email campaigns using real devices, then this post may be beneficial to you. In Outlook 2010 for example, hyperlinks in their visited state, may turn purple after you click on them, even if you explicitly declare an inline CSS color [&hellip;]","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[12],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>HTML email hyperlinks - prevent them from turning purple after clicking<\/title>\n<meta name=\"description\" content=\"Learn how to prevent HTML email hyperlinks from turning purple after clicking on them in an email, even if an inline CSS color style has been applied.\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HTML email hyperlinks - prevent them from turning purple after clicking\" \/>\n<meta property=\"og:description\" content=\"Learn how to prevent HTML email hyperlinks from turning purple after clicking on them in an email, even if an inline CSS color style has been applied.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/purple-html-email-hyperlinks\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Development Reference\" \/>\n<meta property=\"article:published_time\" content=\"2016-04-30T03:32:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-05-15T20:58:14+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-content\/uploads\/2016\/04\/email_anchor_tags_linked-300x20.png\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"3 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/#website\",\"url\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/\",\"name\":\"Web Development Reference\",\"description\":\"Web Development Solutions Explained -- Easy\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/purple-html-email-hyperlinks\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-content\/uploads\/2016\/04\/email_anchor_tags_linked-300x20.png\",\"contentUrl\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-content\/uploads\/2016\/04\/email_anchor_tags_linked-300x20.png\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/purple-html-email-hyperlinks\/#webpage\",\"url\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/purple-html-email-hyperlinks\/\",\"name\":\"HTML email hyperlinks - prevent them from turning purple after clicking\",\"isPartOf\":{\"@id\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/purple-html-email-hyperlinks\/#primaryimage\"},\"datePublished\":\"2016-04-30T03:32:44+00:00\",\"dateModified\":\"2017-05-15T20:58:14+00:00\",\"author\":{\"@id\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/#\/schema\/person\/9624bee17e4fbdcaad7eb7569f5faa70\"},\"description\":\"Learn how to prevent HTML email hyperlinks from turning purple after clicking on them in an email, even if an inline CSS color style has been applied.\",\"breadcrumb\":{\"@id\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/purple-html-email-hyperlinks\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/purple-html-email-hyperlinks\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/purple-html-email-hyperlinks\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/\",\"url\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/purple-html-email-hyperlinks\/\",\"url\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/purple-html-email-hyperlinks\/\",\"name\":\"Prevent anchor elements from turning purple after clicking in HTML emails\"}}]},{\"@type\":\"Person\",\"@id\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/#\/schema\/person\/9624bee17e4fbdcaad7eb7569f5faa70\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"http:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c0c4e0ed219e3aaa419ce72b52646d59?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c0c4e0ed219e3aaa419ce72b52646d59?s=96&d=mm&r=g\",\"caption\":\"admin\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7o7aF-1p","_links":{"self":[{"href":"https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-json\/wp\/v2\/posts\/87"}],"collection":[{"href":"https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-json\/wp\/v2\/comments?post=87"}],"version-history":[{"count":16,"href":"https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-json\/wp\/v2\/posts\/87\/revisions"}],"predecessor-version":[{"id":269,"href":"https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-json\/wp\/v2\/posts\/87\/revisions\/269"}],"wp:attachment":[{"href":"https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-json\/wp\/v2\/media?parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-json\/wp\/v2\/categories?post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.pixelprofessionals.com\/webdevelopmentreference\/wp-json\/wp\/v2\/tags?post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}