{"id":2720,"date":"2011-04-14T10:13:05","date_gmt":"2011-04-14T14:13:05","guid":{"rendered":"http:\/\/www.useragentman.com\/blog\/?p=2720"},"modified":"2013-12-30T13:35:00","modified_gmt":"2013-12-30T17:35:00","slug":"css3-text-shadow-can-it-be-done-in-ie-without-javascript","status":"publish","type":"post","link":"https:\/\/www.useragentman.com\/blog\/2011\/04\/14\/css3-text-shadow-can-it-be-done-in-ie-without-javascript\/","title":{"rendered":"CSS3 Text-Shadow &#8211; Can It Be Done in IE Without JavaScript?"},"content":{"rendered":"<div class=\"importantNotes\">\n<h3>Update: April 24, 2011<\/h3>\n<p>Since writing this article, I have also discovered <a href=\"https:\/\/www.useragentman.com\/blog\/2011\/04\/23\/css-blurred-text-shadow-in-ie-part-i\/\">a way to implement blurred text-shadows in IE9+<\/a>.\n<\/div>\n<div class=\"importantNotes\">\n<h3>Update: July 13, 2011<\/h3>\n<p>You may want to read <a href=\"https:\/\/www.useragentman.com\/blog\/2011\/06\/29\/full-css3-text-shadows-even-in-ie\/\">my subsequent article<\/a>, which covers <strong>using my cssSandpaper JavaScript library to produce multiple blurred and un-blurred text-shadows in IE7+.<\/strong><\/p>\n<\/div>\n<div id=\"introExample\" class=\"alignLeft\">\n<p>CSS3 + IE<\/p>\n<\/div>\n<p>When IE9 was released, I was really happy to see all the great CSS3 features it supported.  2D Transforms, advanced selectors, border-radius, rgba\/hsla colors, WOFF fonts &#8230; the list goes on.  And no polyfills required!  <strong>I was, however, disappointed that IE9 doesn&#8217;t support two of my favorite CSS3 effects: <code>border-image<\/code> and <code>text-shadow<\/code>.<\/strong>  I&#8217;m sure that I will notice other CSS3 effects missing over time, but these are two features that I currently find incredibly useful. This article will deal with <code>text-shadow<\/code>: how it works in browsers that support it, and strategies we can use today to emulate some of its functionality in IE.  <strong>Although the solutions I present here are based on IE&#8217;s Visual Filters,<\/strong> and that some articles like <a href=\"http:\/\/www.workingwith.me.uk\/articles\/css\/cross-browser-drop-shadows\">this one by Neil Crosby<\/a> have looked into it as a solution, <strong>I present here some new information<\/strong> &#8211; how to make them work correctly with Windows Standard and ClearType font-smoothing and how to write the final CSS that won&#8217;t break any browser.<\/p>\n<h2>How does CSS3 <code>text-shadow<\/code> Work?<\/h2>\n<p>Before we go on about IE, let&#8217;s have a quick overview of how the CSS3 specification works.  In all the other browsers (i.e. Firefox 3.0+, Safari 4.0+, Opera 10.0+ and Chrome 4.0+) text-shadow has pretty solid support.  Its basic syntax is:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#obj {\r\n   text-shadow: <em>&lt;x-offset&gt;<\/em> <em>&lt;y-offset&gt;<\/em> <em>&lt;blur-radius&gt;<\/em> <em>&lt;color&gt;<\/em>;\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>The <em>x-offset<\/em> and <em>y-offset<\/em> state how many pixels horizontally and vertically the shadow is positioned with respect to the original text, while the <em>blur-radius<\/em> is used to express how much the shadow is blurred (the higher the value, the more blurry it is).  All of these values can be expressed using any CSS unit of measure (e.g. <code>px<\/code>, <code>em<\/code>, etc).  The <em>color<\/em> can be any CSS color value, representing the color of the text.<\/p>\n<p>Here are some examples:<\/p>\n<table class=\"dataTable screenshots\">\n<thead>\n<tr>\n<th>Pure CSS Example (will be visible if your browser supports <code>text-shadow<\/code><\/th>\n<th>Firefox Screenshot (similar in other browsers except IE)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td id=\"cssExample1\" class=\"test\">text:shadow: 5px 5px 0px black;<\/td>\n<td><img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/example1.png\" alt=\"Screenshot of the text on the left in Firefox.\" \/><\/td>\n<\/tr>\n<tr>\n<td id=\"cssExample2\" class=\"test\">text:shadow: 5px 5px 5px black;<\/td>\n<td><img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/example2.png\" alt=\"Screenshot of the text on the left in Firefox.\" \/><\/td>\n<\/tr>\n<tr>\n<td id=\"cssExample3\" class=\"test\">text:shadow: 1px 0px 0px white;<\/td>\n<td class=\"example3\"><img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/example3.png\" alt=\"Screenshot of the text on the left in Firefox.\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>You are not restricted to just one shadow.  You can have multiple shadows, separated by commas.  For example:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#obj {\r\n\ttext-shadow: \r\n\t\t 1px -1px 5px rgba(0, 0, 0, 0.2),\r\n\t\t-1px  1px 5px rgba(0, 0, 0, 0.2),\r\n\t\t 1px  1px 5px rgba(0, 0, 0, 0.2),\r\n\t\t-1px -1px 5px rgba(0, 0, 0, 0.2),\r\n\t\t 0px  1px 5px rgba(0, 0, 0, 0.2),\r\n\t\t 0px -1px 5px rgba(0, 0, 0, 0.2),\r\n\t\t 1px  0px 5px rgba(0, 0, 0, 0.2),\r\n\t\t-1px  0px 5px rgba(0, 0, 0, 0.2);\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>renders white text legibly on a white background:<\/p>\n<table class=\"dataTable screenshots\">\n<thead>\n<tr>\n<th>Pure CSS Example (will be visible if your browser supports <code>text-shadow<\/code><\/th>\n<th>Firefox Screenshot (similar in other browsers except IE)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td id=\"white\" class=\"test\">\nThis is white text on a white background\n<\/td>\n<td><img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/example4.png\" alt=\"Screenshot of the text on the left in Firefox.\" \/><\/td>\n<\/tr>\n<tr>\n<\/tbody>\n<\/table>\n<h2>Well &#8230; What About IE?<\/h2>\n<p><strong>Currently, no version of Internet Explorer natively understands the CSS3 Syntax for <code>text-shadow<\/code>. <\/strong> However, IE 4.0+ can do text-shadow-like effects using Microsoft&#8217;s proprietary <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms532853%28v=vs.85%29.aspx\">Visual Filters<\/a> &#8212; unfortunately, if the user&#8217;s computer has any type of font-smoothing technology enabled, the <strong><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms532985%28v=vs.85%29.aspx\"><code>DropShadow<\/code><\/a> Visual Filter effect is quite messy and ugly<\/strong>.  Since <a href=\"http:\/\/blogs.msdn.com\/b\/e7\/archive\/2009\/06\/23\/engineering-changes-to-cleartype-in-windows-7.aspx\">ClearType is enabled by default<\/a> in modern versions of the Windows operating system (i.e. Vista, Windows 7) and is <a href=\"http:\/\/social.technet.microsoft.com\/Forums\/en\/ieitprocurrentver\/thread\/01c447b1-5c78-4d2f-9968-6eeabc04a68b\">very difficult to disable it in Internet Explorer 9<\/a>, this is a show-stopper. <strong>Don&#8217;t dispair, there is a workaround.<\/strong> Let&#8217;s see how <code>DropShadow<\/code> is supposed to work, and see how <strong>we can &#8220;clean-up&#8221; the result to look much nicer in modern versions of Windows.<\/strong><\/p>\n<h3>Basic Text-Shadow<\/h3>\n<p>Let&#8217;s first take a look at a basic text-shadow without any blurring of the shadow:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#basicTextShadow {\r\n\tbackground-color: white;\r\n}\r\n\r\n#basicTextShadow p {\r\n\ttext-shadow: <span class=\"hilite2\">3px 3px<\/span> 0px <span class=\"hilite3\">#99cc99<\/span>;\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>The equivalent Visual Filter syntax is:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n\r\n#basicTextShadow {\r\n\tbackground-color: white;\r\n}\r\n\r\n#basicTextShadow p {\r\n\tzoom: 1;\r\n\tfilter: progid:DXImageTransform.Microsoft.DropShadow(<span class=\"hilite2\">OffX=3, OffY=3<\/span>, <span class=\"hilite3\">Color=#99cc99<\/span>);\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>Note that the <code>zoom<\/code> line &mdash; it is here since it <a href=\"http:\/\/www.satzansatz.de\/cssd\/onhavinglayout.html\">forces IE to recognize that the object &#8220;has layout&#8221;<\/a>.  Visual Filters do not work unless a node &#8220;has layout&#8221;.<\/p>\n<p>The problem is that when ClearType is turned on, many Visual Filters, including <code>DropShadow<\/code> don&#8217;t render text very well:<\/p>\n<table class=\"dataTable  screenshots\">\n<thead>\n<tr>\n<th>IE <code>DropShadow<\/code> without ClearType<\/code><\/th>\n<th>IE <code>DropShadow<\/code> with ClearType<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<td><img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/justDropShadowWithoutFontSmoothing.png\" alt=\"IE DropShadow without ClearType\" \/>\n<\/td>\n<td><img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/justDropShadowWithFontSmoothing.png\" alt=\"IE DropShadow with ClearType\" \/>\n<\/td>\n<\/tbody>\n<\/table>\n<p>The text renders much better when you have a <code>background-color<\/code>.  <\/p>\n<blockquote class=\"code\">\n<pre>\r\n#basicTextShadow p {\r\n\tzoom: 1;\r\n\t<span class=\"hilite\">background-color: white;<\/span>\r\n\tfilter: progid:DXImageTransform.Microsoft.DropShadow(OffX=3, OffY=3, Color=#99cc99);\r\n}\r\n<\/pre>\n<\/blockquote>\n<p><div id=\"attachment_2882\" style=\"width: 335px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/dropShadowWithBackground.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2882\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/dropShadowWithBackground.png\" alt=\" IE using the DropShadow Visual Filter with a &lt;code&gt;background-color&lt;\/code&gt;.\" title=\"dropShadowWithBackground\" width=\"325\" height=\"130\" class=\"size-full wp-image-2882\" srcset=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/dropShadowWithBackground.png 325w, https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/dropShadowWithBackground-300x120.png 300w\" sizes=\"auto, (max-width: 325px) 100vw, 325px\" \/><\/a><p id=\"caption-attachment-2882\" class=\"wp-caption-text\"> IE using the <code>DropShadow<\/code> Visual Filter with a <code>background-color<\/code>.<\/p><\/div><\/p>\n<p>However, this will cause <code>DropShadow<\/code> to behave more like the CSS3 <code>box-shadow<\/code> property.<\/p>\n<p>How can we have the font render well <em>without<\/em> the <code>background-color<\/code>.  All we have to do is cut-out the background-color using the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms532982%28v=vs.85%29.aspx\"><code>Chroma<\/code> filter<\/a>:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#basicTextShadow p {\r\n\tzoom: 1;\r\n\tbackground-color: <span class=\"hilite\">white<\/span>;\r\n\tfilter: progid:DXImageTransform.Microsoft.Chroma(Color=<span class=\"hilite\">white<\/span>)\r\n\t\tprogid:DXImageTransform.Microsoft.DropShadow(OffX=3, OffY=3, Color=#99cc99);\r\n}\r\n<\/pre>\n<\/blockquote>\n<table class=\"dataTable\">\n<thead>\n<tr>\n<th>Firefox using CSS3 <code>text-shadow<\/code><\/th>\n<th>IE with <code>Chroma<\/code> and <code>DropShadow<\/code> Filters Applied<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<td><img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/firefoxBasic.png\" alt=\"Firefox Using CSS3 Syntax.\" \/>\n<\/td>\n<td><img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/dropShadowWithBackgroundAndChroma.png\" alt=\"IE with Chroma and DropShadow Filters Applied\" \/>\n<\/td>\n<\/tbody>\n<\/table>\n<p><strong>The Chroma filter allows us to remove a specific color from the rendered element.<\/strong>  In this case, we are removing white, which is also the background-color.  As a result the font renders smoothly, and the <code>DropShadow<\/code> filter behaves almost like a true <code>text-shadow<\/code>.  This is similar to the method I describe in a previous article I wrote, <a href=\"https:\/\/www.useragentman.com\/blog\/2010\/09\/02\/how-to-make-cleartype-font-face-fonts-and-css-visual-filters-play-nicely-together\/\" rel=\"bookmark\" title=\"Permanent Link to How to Make ClearType, @font-face Fonts and CSS Visual Filters Play Nicely Together\">How to Make ClearType, @font-face Fonts and CSS Visual Filters Play Nicely Together<\/a>.  To sum-up: regardless of whether you use @font-face or not, you can make Visual Filters render text correctly by creating a background for the element, and then removing that background with the <code>Chroma<\/code> filter.<\/p>\n<p><a class=\"exampleLink\" href=\"https:\/\/www.useragentman.com\/tests\/textShadow\/example1.html\">See the above three examples in action (IE is recommended in order to see the Visual Filter differences)<\/a><\/p>\n<p>Here is some actual HTML that is styled so that all browsers, including IE, will render a text-shadow correctly:<\/p>\n<div id=\"basicTextShadow\" class=\"test\">\n<p>This is an example of a basic text-shadow.  Note that is looks almost the same in browsers that understand CSS3 text-shadow as well as Internet Explorer, which doesn&#8217;t.<\/p>\n<\/div>\n<p>Here is the CSS for &#8220;compliant&#8221; web-browsers:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#basicTextShadow p {\r\n\ttext-shadow: <span class=\"hilite2\">3px 3px<\/span> 0px <span class=\"hilite3\">#99cc99<\/span>;\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>And here is the CSS for IE (using <a href=\"http:\/\/paulirish.com\/2008\/conditional-stylesheets-vs-css-hacks-answer-neither\/\">Paul Irish\u2019s Conditional CSS Pattern<\/a>):<\/p>\n<blockquote class=\"code\">\n<pre>\r\nbody.ie6 #basicTextShadow p,\r\nbody.ie7 #basicTextShadow p,\r\nbody.ie8 #basicTextShadow p,\r\nbody.ie9 #basicTextShadow p {\r\n\tzoom: 1;\r\n\tbackground-color: <span class=\"hilite\">#cccccc;<\/span>\r\n\tfilter: progid:DXImageTransform.Microsoft.Chroma(Color=<span class=\"hilite\">#cccccc<\/span>)\r\n\t        progid:DXImageTransform.Microsoft.DropShadow(<span class=\"hilite2\">OffX=3, OffY=3<\/span>, <span class=\"hilite3\">Color=#99cc99<\/span>);\r\n}\r\n<\/pre>\n<\/blockquote>\n<p><strong>There are some things that you should keep in mind with this solution:<\/strong><\/p>\n<ul>\n<li>Since we are using the <code>Chroma<\/code> filter to remove the <code>background-color<\/code> of the object, <strong>any background image or color that you want to appear in the document must be placed in the containing tag<\/strong>.  In this example, the background-image is styled on a <code>&lt;div&gt;<\/code> tag, while the text-shadow appears in a <code>&lt;p&gt;<\/code> tag inside it.<\/li>\n<li><strong>Unlike CSS3, it is impossible to use multiple shadows using Visual Filters<\/strong> (to be more accurate: it is syntactically possible, but it doesn&#8217;t look good or behave as one would expect).<\/li>\n<li>According to Microsoft&#8217;s documentation, <strong>IE8+ is required to have an extra line containing an <code>-ms-filter<\/code> property<\/strong> which is identical to the <code>filter<\/code> one except the property&#8217;s value is contained on one line within a set of quotation marks.<br \/>\n<blockquote class=\"code\">\n<pre>\r\nbody.ie6 #basicTextShadow p,\r\nbody.ie7 #basicTextShadow p,\r\nbody.ie8 #basicTextShadow p,\r\nbody.ie9 #basicTextShadow p {\r\n\tzoom: 1;\r\n\tbackground-color: #cccccc;\r\n\t<span class=\"hilite\">-ms-filter: \"progid:DXImageTransform.Microsoft.Chroma(Color=#cccccc) progid:DXImageTransform.Microsoft.DropShadow(Color=#99cc99, OffX=3, OffY=3)\";<\/span> \r\n\tfilter: progid:DXImageTransform.Microsoft.Chroma(Color=#cccccc)\r\n\t        progid:DXImageTransform.Microsoft.DropShadow(OffX=3, OffY=3, Color=#99cc99);\r\n}\r\n\r\n<\/pre>\n<\/blockquote>\n<p>I have, however, noticed that the CSS works in IE9 standards mode without this additional line.<\/li>\n<\/ul>\n<h3>Text Glowing<\/h3>\n<p>Text glowing is a term to describe a shadow that &#8220;envelopes&#8221; some text in a glow of color to make it more legible.  Let&#8217;s take the following example of black text on a dark background:<\/p>\n<div id=\"sky\" class=\"test\">\n<p>This is dark text on a dark background.<\/p>\n<\/div>\n<p>Hard to read, isn&#8217;t it?  We could change the color of the text to white, but you could also put a white glow around the text to keep it black and maintain the dark atmosphere of the image:<\/p>\n<div id=\"sky\" class=\"test textShadowTest\">\n<p>This is dark text on a dark background.<\/p>\n<\/div>\n<p>Using the CSS3 <code>text-shadow<\/code> property, this is just a case of creating a set of eight shadows around the text in question:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#sky.textShadowTest p {\r\n\ttext-shadow: \r\n\t\t 0px -1px <span class=\"hilite2\">5px<\/span> <span class=\"hilite3\">#eeeeee<\/span>,     \/* north      *\/\r\n\t\t 0px  1px <span class=\"hilite2\">5px<\/span> <span class=\"hilite3\">#eeeeee<\/span>,     \/* south      *\/\r\n\t\t-1px  0px <span class=\"hilite2\">5px<\/span> <span class=\"hilite3\">#eeeeee<\/span>,     \/* west       *\/\r\n\t\t 1px  0px <span class=\"hilite2\">5px<\/span> <span class=\"hilite3\">#eeeeee<\/span>,     \/* east       *\/\r\n\t\t-1px -1px <span class=\"hilite2\">5px<\/span> <span class=\"hilite3\">#eeeeee<\/span>,     \/* north-west *\/\r\n\t\t-1px  1px <span class=\"hilite2\">5px<\/span> <span class=\"hilite3\">#eeeeee<\/span>,     \/* north-east *\/\r\n\t\t 1px -1px <span class=\"hilite2\">5px<\/span> <span class=\"hilite3\">#eeeeee<\/span>,     \/* south-west *\/\r\n\t\t 1px  1px <span class=\"hilite2\">5px<\/span> <span class=\"hilite3\">#eeeeee<\/span>;     \/* south-east *\/\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>It basically creates a text-shadow in all eight directions and blurs them together, giving us a glow effect.  Pretty neat, but it doesn&#8217;t work in Internet Explorer.  However adding this CSS code will give IE something <em>roughly<\/em> equivalent:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n\r\n\/* Use <a href=\"http:\/\/paulirish.com\/2008\/conditional-stylesheets-vs-css-hacks-answer-neither\/\"\r\n>Paul Irish\u2019s Conditional CSS Pattern<\/a> to isolate the rule for Internet Explorer *\/\r\nbody.ie6 #sky.textShadowTest p,\r\nbody.ie7 #sky.textShadowTest p,\r\nbody.ie8 #sky.textShadowTest p,\r\nbody.ie9 #sky.textShadowTest p {\r\n\tbackground-color: #cccccc;\r\n\tfilter: progid:DXImageTransform.Microsoft.Chroma(Color=#cccccc)\r\n\t\tprogid:DXImageTransform.Microsoft.Glow(<span class=\"hilite2\">Strength=5<\/span>, Color=<span class=\"hilite3\">#eeeeee<\/span>); \r\n}\r\n<\/pre>\n<\/blockquote>\n<table class=\"dataTable smallDataTable\">\n<thead>\n<tr>\n<th>Firefox using CSS3<br \/><code>text-shadow<\/code><\/p>\n<th>IE using the <code>Chroma<\/code><br \/>and <code>Glow<\/code> Visual Filter.<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<td><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/FirefoxGlow.png\" alt=\"\" title=\"FirefoxGlow\" width=\"170\" height=\"92\" class=\"alignnone size-full wp-image-2780\" \/>\n<\/td>\n<td>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/IEGlow.png\" alt=\"\" title=\"FirefoxGlow\" width=\"170\" height=\"92\" class=\"alignnone size-full wp-image-2780\" \/>\n<\/td>\n<\/tbody>\n<\/table>\n<p>Note a few things about this solution:<\/p>\n<ol>\n<li>The results aren&#8217;t exactly the same.  Doing a side by side comparison reveals that the CSS3 version looks a little smoother. Here are the above examples blown up 300% to show detail:<br \/>\n<table class=\"dataTable smallDataTable\">\n<thead>\n<tr>\n<th>Firefox using CSS3<br \/><code>text-shadow<\/code><\/p>\n<th>IE using the <code>Chroma<\/code><br \/>and <code>Glow<\/code> Visual Filter.<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<td><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/FirefoxGlowScaled.png\" alt=\"\" title=\"FirefoxGlow\" width=\"170\" height=\"92\" class=\"alignnone size-full wp-image-2780\" \/>\n<\/td>\n<td>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/IEGlowScaled.png\" alt=\"\" title=\"FirefoxGlow\" width=\"170\" height=\"92\" class=\"alignnone size-full wp-image-2780\" \/>\n<\/td>\n<\/tbody>\n<\/table>\n<\/li>\n<li>The <code>Strength<\/code> in the <code>Glow<\/code> filter is the same amount of pixels in the blur-factor in the CSS3 <code>text-shadow<\/code> code.<\/li>\n<li>You&#8217;ll notice that <code>background-color<\/code> I removed with the <code>Chroma<\/code> filter in this case is not blue, but gray, a color halfway between the color of the text (black) and the color or the glowing text (white).  This is so that the smoothness obtained by ClearType is somewhat preserved. Choosing black would make the text look to &#8220;thick&#8221;, while choosing white would make the text look too &#8220;thin&#8221;.<\/li>\n<li>You&#8217;ll notice the IE glowing text is &#8220;pushed&#8221; a little down and to the right.  That&#8217;s because IE treats the <code>Glow<\/code> as part of the width and height of the element.  This can be fixed by relatively positioning the object and setting the <code>top<\/code> and <code>left<\/code> properties to the negative value of <code>Glow<\/code>&#8216;s <code>Strength<\/code> value to compensate:<br \/>\n<blockquote class=\"code\">\n<pre>\r\nbody.ie6 #sky.textShadowTest p,\r\nbody.ie7 #sky.textShadowTest p,\r\nbody.ie8 #sky.textShadowTest p,\r\nbody.ie9 #sky.textShadowTest p {\r\n\tzoom: 1;\r\n\tbackground-color: #cccccc;\r\n\tfilter: progid:DXImageTransform.Microsoft.Chroma(Color=#cccccc)\r\n\t\tprogid:DXImageTransform.Microsoft.Glow(Color=#eeeeee, Strength=3);\r\n\t<span class=\"hilite\">position: relative;<\/span>\r\n\t<span class=\"hilite\">top: -3px;<\/span>\r\n\t<span class=\"hilite\">left: -3px;<\/span>\r\n}\r\n\r\n<\/pre>\n<\/blockquote>\n<p>The results are subtle, but will help to make the result a little more pixel perfect. <\/p>\n<table class=\"dataTable smallDataTable\">\n<thead>\n<tr>\n<th>Firefox using CSS3<br \/><code>text-shadow<\/code><\/p>\n<th>IE using the modified<br \/>version of the <code>Chroma<\/code><br \/>fix.<\/th>\n<th>IE using the both <br \/>positioning and modified<br \/><code>Chroma<\/code><br \/>fix.<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<td><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/FirefoxGlow.png\" alt=\"\" title=\"FirefoxGlow\" width=\"170\" height=\"92\" class=\"alignnone size-full wp-image-2780\" \/>\n<\/td>\n<td>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/IEGlow.png\" alt=\"\" title=\"FirefoxGlow\" width=\"170\" height=\"92\" class=\"alignnone size-full wp-image-2780\" \/>\n<\/td>\n<td>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/IEGlow2.png\" alt=\"\" title=\"FirefoxGlow\" width=\"170\" height=\"92\" class=\"alignnone size-full wp-image-2780\" \/>\n<\/td>\n<\/tbody>\n<\/table>\n<p> If you don&#8217;t like using relatively positioning the text, you can also use negative left and top margins to achieve the same effect, or you can leave it the way it is &mdash; after all, what are a few pixels between friends? ;-)<\/p>\n<\/li>\n<\/ol>\n<p>I have used this method in <a href=\"\/blog\/2011\/03\/29\/pixel-perfect-css3-border-image-in-depth\/\">my previous blog post<\/a> about CSS3 <code>border-image<\/code>:<\/p>\n<table class=\"dataTable\">\n<thead>\n<tr>\n<th>Firefox<\/th>\n<th>IE9<\/th>\n<\/thead>\n<tbody>\n<td><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/03\/firefoxFallback.png\" alt=\"Screenshot of how the border-image example at the top of the page looks in Firefox.\" title=\"Screenshot of how the border-image example at the top of the page looks in Firefox.\" width=\"355\" height=\"284\" class=\"size-full wp-image-2634\" srcset=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/03\/firefoxFallback.png 355w, https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/03\/firefoxFallback-300x240.png 300w\" sizes=\"auto, (max-width: 355px) 100vw, 355px\" \/><\/td>\n<td><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/03\/IEfallback.png\" alt=\"Screenshot of how the border-image example &#039;falls back&#039; in IE9.\" title=\"Screenshot of how the border-image example &#039;falls back&#039; in IE9.\" width=\"362\" height=\"291\" class=\"size-full wp-image-2633\" srcset=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/03\/IEfallback.png 362w, https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/03\/IEfallback-300x241.png 300w\" sizes=\"auto, (max-width: 362px) 100vw, 362px\" \/><\/td>\n<\/tbody>\n<\/table>\n<p>Here is the CSS that I used to produce it:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#introExample p, #introExample code {  \r\n   color: white;\r\n   text-shadow:   2px  2px 3px #333333,\r\n                 -2px -2px 3px #333333,\r\n                 -2px  2px 3px #333333,\r\n                  2px -2px 3px #333333;\r\n}\r\n\r\n\/* \r\n * The \"poor man's\" version of text-shadow for IE's Visual filters.\r\n *\/\r\nbody.ie6 #introExample p,\r\nbody.ie7 #introExample p,\r\nbody.ie8 #introExample p,\r\nbody.ie9 #introExample p {\r\n\tzoom: 1;\r\n\tbackground: #000003; \r\n\tfilter: progid:DXImageTransform.Microsoft.Chroma(Color=#000003) \r\n\t\tprogid:DXImageTransform.Microsoft.Glow(Color=#3e3e3e, Strength=4); \r\n\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>The values of the Visual Filter code doesn&#8217;t match exactly with the <code>text-shadow<\/code>.  This is in part that I only used four directions in the <code>text-shadow<\/code> code (i.e. south-east, north-west, north-east and south-west).  I don&#8217;t believe this conversion is an exact science &#8230; it is worth your time to experiment with these values, using the examples in this article as a guide.<\/p>\n<h2>But How About Other Types Of Shadows?<\/h2>\n<p><strike>The short answer for now is that you are out of luck.  There are no Visual Filters, as far as I know, that will allow you to do other types of shadowing, like a Basic Text-Shadow with blurring:<\/strike> <strong>Update April 24, 2011:<\/strong> Since writing this article, I have a discovered <a href=\"https:\/\/www.useragentman.com\/blog\/2011\/04\/23\/css-blurred-text-shadow-in-ie-part-i\/\">a way to implement blurred text-shadows in IE9+<\/a>.  I have left the rest of the information here since it is still relevant, interesting and influenced my own work.<\/p>\n<p><div id=\"attachment_2848\" style=\"width: 390px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/example2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2848\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/example2.png\" alt=\"An example of a basic text shadow with blurring.\" title=\"example2\" width=\"380\" height=\"90\" class=\"size-full wp-image-2848\" srcset=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/example2.png 380w, https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/example2-300x71.png 300w\" sizes=\"auto, (max-width: 380px) 100vw, 380px\" \/><\/a><p id=\"caption-attachment-2848\" class=\"wp-caption-text\">There is no way that I know to do this in IE without JavaScript or without affecting the DOM<\/p><\/div><\/p>\n<p><a href=\"http:\/\/kilianvalkhof.com\/\">Kilian Valkhob<\/a> also has <a href=\"http:\/\/kilianvalkhof.com\/2008\/design\/almost-cross-browser-text-shadow\/\">a solution for this<\/a> which involves making a copy of the desired text and blurring it with the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms532979%28v=vs.85%29.aspx\"><code>Blur<\/code> filter<\/a>. While I think the results look pretty good, I hesitate using this method since search engines may see the text repeated in the document and index that text higher than it should be rated (or they might penalize the document because the search engine thinks the author is trying to do some unethical hack of the page ranking algorithm it uses).  Vilkhob has, however, also created a <a href=\"http:\/\/kilianvalkhof.com\/2008\/javascript\/text-shadow-in-ie-with-jquery\/\">text-shadowing JavaScript library<\/a> that automates this process, and since the repeated text isn&#8217;t actually in the document, it may be a solution to the search engine concern.  This solution is something i am currently looking into adding to cssSandpaper, but I want to do more research into this before I implement it in a public version of my library. For example, how would screen readers handle this JavaScript generated &#8220;double text&#8221;?  <\/p>\n<h2>Conclusion<\/h2>\n<p>CSS3 <code>text-shadow<\/code> is a great effect in a web developer&#8217;s toolkit.  Hopefully IE will natively support it soon, but in the meantime, at least there are some use cases you can use Visual Filters to do some of eye-candy it supports.  <\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/04\/splash.png\" \/> CSS3 <code>text-shadow<\/code> rocks, but it doesn&#8217;t work in any version of Internet Explorer, including IE9.  While it is impossible to replicate all <code>text-shadow<\/code> effects in The Browser That Likes To Be Difficult, there are some ways to emulate this effect without JavaScript using Visual Filters, even when ClearType is enabled.  This article can show you how and contains lots of examples.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51,38,120,99,1],"tags":[104,105,218,102,100,53,44,103,101,52],"class_list":["post-2720","post","type-post","status-publish","format-standard","hentry","category-cleartype-technologies","category-css3","category-ie-visual-filters","category-text-shadow","category-uncategorized","tag-cross-browser-css3-text-shadow","tag-cross-browser-text-shadow","tag-css","tag-css3-text-shadow","tag-dropshadow","tag-ie","tag-ie-filters","tag-ie9","tag-internet-explorer","tag-visual-filters"],"_links":{"self":[{"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/posts\/2720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/comments?post=2720"}],"version-history":[{"count":204,"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/posts\/2720\/revisions"}],"predecessor-version":[{"id":6595,"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/posts\/2720\/revisions\/6595"}],"wp:attachment":[{"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/media?parent=2720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/categories?post=2720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/tags?post=2720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}