{"id":3563,"date":"2011-08-24T00:07:03","date_gmt":"2011-08-24T04:07:03","guid":{"rendered":"http:\/\/www.useragentman.com\/blog\/?p=3563"},"modified":"2012-11-10T15:18:39","modified_gmt":"2012-11-10T19:18:39","slug":"how-to-simulate-css3-box-shadow-in-ie7-8-without-javascript","status":"publish","type":"post","link":"https:\/\/www.useragentman.com\/blog\/2011\/08\/24\/how-to-simulate-css3-box-shadow-in-ie7-8-without-javascript\/","title":{"rendered":"How to Simulate CSS3 <code>box-shadow<\/code> in IE6-8 Without JavaScript."},"content":{"rendered":"<div id=\"intro\">\n<div class=\"box\">\n<span class=\"text\">Simulating CSS3 <code>box-shadow<\/code> in IE6-8 <em>is<\/em> possible!<\/span>\n<\/div>\n<div class=\"description\">The above is not an image.  It uses Allen R. Walden&#8217;s <a href=\"http:\/\/www.fontspace.com\/allen-r-walden\/neon-lights\">Neon Lights<\/a> font and <a href=\"https:\/\/www.useragentman.com\/blog\/2010\/03\/09\/cross-browser-css-transforms-even-in-ie\/\">cssSandpaper<\/a> to simulate CSS3 text-shadowing in IE. The box shadows are made with pure CSS in all browsers.<\/div>\n<\/div>\n<p><strong>CSS3 Box-Shadows are a great to quickly decorate the outside of block-level elements.<\/strong>  There are many CSS box-shadow recipes you can use to produce a variety of effects, including <strong>simple<\/strong>, <strong>glowing<\/strong> and <strong>blurred<\/strong> shadows. And, <a href=\"https:\/\/www.useragentman.com\/blog\/2011\/06\/29\/full-css3-text-shadows-even-in-ie\/\">unlike CSS3 text-shadows<\/a>, <strong>box-shadows are natively supported by the latest version of IE.<\/strong>  However, if you want them to appear in <strong>older versions of IE<\/strong> (i.e. 6 through 8), you will want to <strong>learn how to use a variety of Visual Filters to simulate them.<\/strong>  This article will cover a few CSS3 box-shadow effects, the equivalent Visual Filter recipes for IE 6-8, and the differences between them. <strong>It will also cover the differences in the CSS3 implementations in all the modern browsers.<\/strong>  Box-shadows like the example on the left is possible in all commonly used browsers.<\/p>\n<h2>First off, what is a <code>box-shadow<\/code>?<\/h2>\n<p>A box-shadow is equivalent to a <a href=\"https:\/\/www.useragentman.com\/blog\/2011\/06\/29\/full-css3-text-shadows-even-in-ie\/\">CSS3 <code>text-shadow<\/code><\/a> except it is applied to the box of the block-level element instead of the actual text.  Just like text-shadows, you can have one shadow:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#box {\r\n  box-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>&#8230; three shadows:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#box {\r\n  box-shadow: <em>&lt;x-offset<sub>1<\/sub>&gt;<\/em> <em>&lt;y-offset<sub>1<\/sub>&gt;<\/em> <em>&lt;blur-radius<sub>1<\/sub>&gt;<\/em>, <em>&lt;color<sub>1<\/sub>&gt;<\/em>,\r\n              <em>&lt;x-offset<sub>2<\/sub>&gt;<\/em> <em>&lt;y-offset<sub>2<\/sub>&gt;<\/em> <em>&lt;blur-radius<sub>2<\/sub>&gt;<\/em>, <em>&lt;color<sub>2<\/sub>&gt;<\/em>,\r\n              <em>&lt;x-offset<sub>3<\/sub>&gt;<\/em> <em>&lt;y-offset<sub>3<\/sub>&gt;<\/em> <em>&lt;blur-radius<sub>3<\/sub>&gt;<\/em>, <em>&lt;color<sub>3<\/sub>&gt;<\/em>;\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>&#8230; or as many as you want.  The <code>x-<\/code> and <code>y-offset<\/code>s measure the position of the horizontal and vertical shadow respectively, and the <code>blur-radius<\/code> measures the amount of blur in the shadow.  Let&#8217;s take a look at a simple example:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#box {\r\n  <span class=\"hilite\">box-shadow: 5px 5px 0px #ff0000;<\/span>\r\n}\r\n<\/pre>\n<\/blockquote>\n<table class=\"dataTable firstExample\">\n<thead>\n<tr>\n<th>Live HTML result<\/th>\n<th>Firefox 4.0 Screenshot (for browsers like IE6-8<br \/>\nthat can&#8217;t see the Live result)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<div id=\"box0\">\nThis is an example of a simple box-shadow without blurring\n<\/div>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/box11.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Note that although <code>box-shadow<\/code> is the official property name, one must use the vendor-specific prefixes in order to use it in Webkit browsers (i.e. Chrome and Safari) as well as older versions of Firefox:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#box {\r\n  box-shadow: 5px 5px 0px #ff0000,          \/* Firefox 4.0+, Opera, IE 9 *\/\r\n  -webkit-box-shadow: 5px 5px 0px #ff0000,  \/* Chrome and Safari         *\/\r\n  -moz-box-shadow: 5px 5px 0px #ff0000;     \/* Firefox 3.6               *\/\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>Furthermore, there are two optional parameters, the <em>spread<\/em> (which allows you to determine the size of the shadow) as well as the <code>inset<\/code> parameter that can allow you to put the shadow inside the box instead of outside of the box.  I direct readers to <a href=\"https:\/\/developer.mozilla.org\/En\/CSS\/Box-shadow\">Mozilla.org&#8217;s great reference for <code>box-shadow<\/code><\/a> to read more on these properties, since they are not, as far as I can tell, reproducible in IE 8 or lower. <\/p>\n<h2 id=\"WhatAboutIE\" name=\"WhatAboutIE\">What about IE?<\/h2>\n<p><strong>IE9 has no problem showing <code>box-shadow<\/code><\/strong> <a href=\"http:\/\/stackoverflow.com\/questions\/5617455\/issue-with-box-shadow-on-ie9\">except when shadowing a box within a table-cell<\/a> (If the CSS of the table has its <code>border-collapse<\/code> property set to <code>collapse<\/code> then the <code>box-shadow<\/code> is not applied.  Hopefully this is fixed in a future release). <\/p>\n<p>As mentioned earlier, <strong>IE6-8 requires Visual Filters to simulate CSS3 box-shadows without JavaScript.<\/strong>  In order to illustrate this, I will show several different types of box-shadows below and show both the CSS3 syntax and the equivalent Visual Filter CSS recipe.  Some of these recipes produce almost identical results, while others are rough equivalents.  Note that all these examples use a variation of <a href=\"http:\/\/paulirish.com\/2008\/conditional-stylesheets-vs-css-hacks-answer-neither\/\">Paul Irish\u2019s Conditional CSS Pattern<\/a> in order to create the IE-only rules.  This involves replacing the <code>&lt;body&gt;<\/code> tag of the document with this HTML:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n   &lt;!-- Extra white-space below is just to make it easier to read. :-) --&gt;\r\n\r\n   &lt;!--[if lt IE 7 ]&gt;   &lt;body class=\"ie6\"&gt;          &lt;![endif]--&gt;\r\n   &lt;!--[if IE 7 ]&gt;      &lt;body class=\"ie7\"&gt;          &lt;![endif]--&gt;\r\n   &lt;!--[if IE 8 ]&gt;      &lt;body class=\"ie8\"&gt;          &lt;![endif]--&gt;\r\n   &lt;!--[if IE 9 ]&gt;      &lt;body class=\"ie9\"&gt;          &lt;![endif]--&gt;\r\n   &lt;!--[if (gt IE 9) ]&gt; &lt;body class=\"modern\"&gt;       &lt;![endif]--&gt;\r\n   &lt;!--[!(IE)]&gt;&lt;!--&gt;    &lt;body class=\"notIE modern\"&gt; &lt;!--&lt;![endif]--&gt;\r\n\r\n<\/pre>\n<\/blockquote>\n<p>We can then apply CSS specific to a version of IE.  For example:<\/p>\n<blockquote class=\"code\">\n<pre>\r\nbody.ie7 #box {\r\n   \/* insert IE7 specific CSS here *\/\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>(<strong>Note:<\/strong> Paul Irish&#8217;s technique officially has the conditional comments around the <code>html<\/code> tag, not the <code>body<\/code> tag.  You can use either for these techniques to work.  I just prefer using the latter.)<\/p>\n<p><strong>All these Visual Filter recipes depend on the box <a href=\"http:\/\/www.satzansatz.de\/cssd\/onhavinglayout.html\">&#8220;having layout&#8221;<\/a>.<\/strong>  If you have any difficulty with the Visual Filters activating, set <code>zoom: 1<\/code> or a static width inside the IE6-8 specific CSS to force the block to have layout.<\/p>\n<h3>Type #1: Simple, Unblurred Shadows<\/h3>\n<p>In order to <strong>simulate simple, unblurred <code>box-shadow<\/code>s in IE<\/strong>, we use <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms532985%28v=vs.85%29.aspx\">IE&#8217;s <code>DropShadow<\/code> Visual filter<\/a>: <\/p>\n<blockquote class=\"code\">\n<pre>\r\n#box {\r\n  \/* CSS for all browsers. *\/\r\n  border: solid 1px #808080;\r\n  background: #ffffcc;\r\n  margin: 10px;\r\n  padding: 10px;\r\n\r\n  \/* CSS3 Box-shadow code: *\/\r\n  box-shadow: <span class=\"hilite\">5px<\/span> <span class=\"hilite2\">5px<\/span> 0px <span class=\"hilite3\">#ff0000<\/span>;\r\n  -webkit-box-shadow: 5px 5px 0px #ff0000;\r\n  -moz-box-shadow: 5px 5px 0px #ff0000;\r\n}\r\n\r\n\/* IE6-8 Specific Code *\/\r\nbody.ie6 #box,\r\nbody.ie7 #box,\r\nbody.ie8 #box {\r\n   zoom: 1;\r\n   filter: progid:DXImageTransform.Microsoft.DropShadow(<span class=\"hilite\">OffX=5<\/span>, <span class=\"hilite2\">OffY=5<\/span>, <span class=\"hilite3\">Color=#ff0000<\/span>);\r\n}\r\n<\/pre>\n<\/blockquote>\n<table class=\"dataTable\">\n<thead>\n<tr>\n<th>Live HTML result<\/th>\n<th>Firefox Screenshot<\/th>\n<th>IE7 Screenshot<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<div id=\"box1\">\nThis is an example of a simple box-shadow without blurring <strong>that also works in IE6-8.<\/strong>\n<\/div>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/box2Firefox.png\"   \/>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/box2IE.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>There are two exceptions to this solution.<\/strong> The first deals with when the block has a <strong>transparent background<\/strong>, and the other has to do with <strong>negative box-shadow offsets<\/strong>.<\/p>\n<h3>Type #1a: Blocks With Transparent Backgrounds<\/h3>\n<p>Let&#8217;s say you use the above CSS, but omit the <code>background<\/code> property:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#box {\r\n  \/* CSS for all browsers.  Note there is no background-color, so box will be transparent *\/\r\n  border: solid 1px #808080;\r\n  margin: 10px;\r\n  padding: 10px;\r\n\r\n  \/* CSS3 Box-shadow code: *\/\r\n  box-shadow: 5px 5px 0px #ff0000;\r\n  -webkit-box-shadow: 5px 5px 0px #ff0000;\r\n  -moz-box-shadow: 5px 5px 0px #ff0000;\r\n}\r\n\r\n\/* IE6-8 Specific Code *\/\r\nbody.ie6 #box,\r\nbody.ie7 #box,\r\nbody.ie8 #box {\r\n   zoom: 1;\r\n   filter: progid:DXImageTransform.Microsoft.DropShadow(OffX=5, OffY=5, Color=#ff0000);\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>Doing this will results in some unexpected results in IE6-8:<\/p>\n<table class=\"dataTable\">\n<thead>\n<tr>\n<th>Live HTML result<\/th>\n<th>Firefox Screenshot<\/th>\n<th>IE7 Screenshot<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"withGrid\">\n<div id=\"box1a\">\nThis is an example of a box with a transparent background and simple box-shadow without blurring. IE6-8 is having a hard time dealing with the transparent background.\n<\/div>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/box3Firefox.png\"   \/>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/box3IE.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The results in IE7 are as hideous and unreadable as the average <a href=\"http:\/\/yourethemannowdog.ytmnd.com\/\">YTMND<\/a> page! In order to fix this issue in elderly IE, one must <strong>add a background color in IE6-8 only and remove it with the <code>Chroma<\/code> filter<\/strong> (more information on this technique can be found on my previous blog post, <a href=\"https:\/\/www.useragentman.com\/blog\/2010\/09\/02\/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>).<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#box {\r\n  border: solid 1px #808080;\r\n  margin: 10px;\r\n  padding: 10px;\r\n\r\n  \/* Box-shadow code: *\/\r\n  box-shadow: 5px 5px 0px #ff0000;\r\n  -webkit-box-shadow: 5px 5px 0px #ff0000;\r\n  -moz-box-shadow: 5px 5px 0px #ff0000;\r\n}\r\n\r\nbody.ie6 #box,\r\nbody.ie7 #box,\r\nbody.ie8 #box {\r\n   background-color: #ffffff;\r\n   zoom: 1;\r\n   filter: progid:DXImageTransform.Microsoft.DropShadow(OffX=5, OffY=5, Color=#ff0000),\r\n           <span class=\"hilite\">progid:DXImageTransform.Microsoft.Chroma(Color='#ffffff');<\/span>\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>As you can see below, adding this CSS logic produces much better results:<\/p>\n<table class=\"dataTable\">\n<thead>\n<tr>\n<th>Live HTML result<\/th>\n<th>Firefox Screenshot<\/th>\n<th>IE7 Screenshot<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"withGrid\">\n<div id=\"box1a-after\">\nThis is an example of a box<br \/>with a transparent background and simple box-shadow<br \/>without blurring, with a fix for IE6-8 to deal with the transparent color.\n<\/div>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/box4Firefox.png\"   \/>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/box4IE.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Note:<\/strong> All the other types of box-shadow recipes that follow should also use this Chroma filter method when it is desirable to have a transparent background in the box itself.<\/p>\n<h3 id=\"type1b\" name=\"type1b\">Type 1b: Negative Shadow Offsets<\/h3>\n<p>If there are negative shadow offsets, you will see a small difference with the position of the box being shadowed:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#box {\r\n  \/* CSS for all browsers. *\/\r\n  border: solid 1px #808080;\r\n  background: #ffffcc;\r\n  margin: 10px;\r\n  padding: 10px;\r\n\r\n  \/* CSS3 Box-shadow code: *\/\r\n  box-shadow: <span class=\"hilite\">-10px<\/span> <span class=\"hilite2\">-5px<\/span> 0px <span class=\"hilite3\">#ff0000<\/span>;\r\n  -webkit-box-shadow: -10px -5px 0px #ff0000;\r\n  -moz-box-shadow: -10px -5px 0px #ff0000;\r\n}\r\n\r\n\/* IE6-8 Specific Code *\/\r\nbody.ie6 #box,\r\nbody.ie7 #box,\r\nbody.ie8 #box {\r\n   zoom: 1;\r\n   filter: progid:DXImageTransform.Microsoft.DropShadow(<span class=\"hilite\">OffX=-10<\/span>, <span class=\"hilite2\">OffY=-5<\/span>, <span class=\"hilite3\">Color=#ff0000<\/span>);\r\n}\r\n<\/pre>\n<\/blockquote>\n<table class=\"dataTable\">\n<thead>\n<tr>\n<th>Live HTML result<\/th>\n<th>Firefox Screenshot<\/th>\n<th>IE7 Screenshot<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"withGrid\">\n<div id=\"box1b\">\nThis is an example of a simple box-shadow without blurring <strong>that also works in IE6-8.<\/strong>\n<\/div>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/box1bFirefox.png\"   \/>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/box1bIE.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>You will note that the offsets in IE push the box down and to the right.  This is because <strong>IE&#8217;s Visual Filters believes that the box-shadow as part of the box itself,<\/strong> while <strong>CSS3 believes that it should be outside of the box.<\/strong>  As a result, negative box-shadows shift the box in IE6-8.  In order to compensate for this, one can use <code>margin-top<\/code> and <code>margin-bottom<\/code> to move the shadow to where CSS3 thinks it should be:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#box {\r\n  \/* CSS3 Box-shadow code: *\/\r\n  box-shadow: <span class=\"hilite\">-10px<\/span> <span class=\"hilite2\">-5px<\/span> 0px <span class=\"hilite3\">#ff0000<\/span>;\r\n  -webkit-box-shadow: -10px -5px 0px #ff0000;\r\n  -moz-box-shadow: -10px -5px 0px #ff0000;\r\n}\r\n\r\n\/* IE6-8 Specific Code *\/\r\nbody.ie6 #box,\r\nbody.ie7 #box,\r\nbody.ie8 #box {\r\n   zoom: 1;\r\n   filter: progid:DXImageTransform.Microsoft.DropShadow(<span class=\"hilite\">OffX=-10<\/span>, <span class=\"hilite2\">OffY=-5<\/span>, <span class=\"hilite3\">Color=#ff0000<\/span>);\r\n   margin-top: <span class=\"hilite\">10px<\/span>;\r\n   margin-left: <span class=\"hilite2\">5px<\/span>;\r\n}\r\n<\/pre>\n<\/blockquote>\n<table class=\"dataTable\">\n<thead>\n<tr>\n<th>Live HTML result<\/th>\n<th>Firefox Screenshot<\/th>\n<th>IE7 Screenshot<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"withGrid\">\n<div id=\"box1b-after\">\nThis is an example of a simple box-shadow without blurring <strong>that also works in IE6-8.<\/strong>\n<\/div>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/box1bFirefox.png\"   \/>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/box1bIE-after.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Note that one could also make use relative positioning and use the CSS <code>top<\/code> and <code>left<\/code> properties to do the same thing in IE.  I leave it up to readers to decide which method would be more appropriate for the situation they find themselves in.<\/p>\n<h3>Type #2: Glowing <code>box-shadow<\/code><\/h3>\n<p>The second <code>box-shadow<\/code> I use a lot is what I call the &#8220;glowing box&#8221; effect.  This happens when a shadow with a large blur radius is put directly behind a box (i.e. the x- and y-offsets are set to 0, and the blur-radius is a non-zero number). It is possible to simulate this effect in IE using the <code>Shadow<\/code> filter. This filter must be applied four times (north, south, east and west of the box) in order to simulate the CSS3 effect.  Here is the CSS recipe:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#box {\r\n   box-shadow: 0 0 5px #666666;\r\n   -webkit-box-shadow: 0 0 5px #666666;\r\n   -moz-box-shadow: 0 0 5px #666666;\r\n}   \r\n\r\nbody.ie6 #box,\r\nbody.ie7 #box,\r\nbody.ie8 #box {\r\n   zoom: 1;\r\n   filter: progid:DXImageTransform.Microsoft.Shadow(Color=#cccccc, Strength=5, Direction=0),\r\n         progid:DXImageTransform.Microsoft.Shadow(Color=#cccccc, Strength=5, Direction=90),\r\n         progid:DXImageTransform.Microsoft.Shadow(Color=#cccccc, Strength=5, Direction=180),\r\n         progid:DXImageTransform.Microsoft.Shadow(Color=#cccccc, Strength=5, Direction=270);\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>&#8230; and here are the results as rendered in Firefox 4 and IE7:<\/p>\n<table class=\"dataTable\">\n<thead>\n<tr>\n<th>Live HTML result<\/th>\n<th>Firefox Screenshot<\/th>\n<th>IE7 Screenshot<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<div id=\"glowShadow1\">\nThis is an example of a box that has short blurred shadows horizontally and vertically on all sides.\n<\/div>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/blurred2Firefox.png\"   \/>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/blurred2IE.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Note that the color in the Visual Filter syntax is lighter than the CSS3 one.  In order to get the equivalent IE color, I take a screenshot of the CSS3 box-shadow, open the image in The GIMP or Photoshop, and find the color that is just outside of the box.  This is the color I use in the IE syntax.  If you don&#8217;t want to go through all this trouble, you can also guess, which is what I do if I&#8217;m lazy.  Which is a lot of the time.<\/p>\n<p>You can increase the blur radius\/strength to produce larger glows as well:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#box {\r\n    box-shadow: 0 0 15px #cccccc;\r\n   -webkit-box-shadow: 0 0 15px #cccccc;\r\n   -moz-box-shadow: 0 0 15px #cccccc;\r\n}\t\r\n\r\nbody.ie6 #box,\r\nbody.ie7 #box,\r\nbody.ie8 #box {\r\n   zoom: 1;\r\n   filter: progid:DXImageTransform.Microsoft.Shadow(Color=#eeeeee, Strength=15, Direction=0),\r\n           progid:DXImageTransform.Microsoft.Shadow(Color=#eeeeee, Strength=15, Direction=90),\r\n           progid:DXImageTransform.Microsoft.Shadow(Color=#eeeeee, Strength=15, Direction=180),\r\n           progid:DXImageTransform.Microsoft.Shadow(Color=#eeeeee, Strength=15, Direction=270);\r\n}\r\n<\/pre>\n<\/blockquote>\n<table class=\"dataTable\">\n<thead>\n<tr>\n<th>Live HTML result<\/th>\n<th>Firefox Screenshot<\/th>\n<th>IE7 Screenshot<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<div id=\"glowShadow2\">\nThis is an example of a box that has longer blurred shadows horizontally and vertically on all sides.\n<\/div>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/blurred2aFirefox.png\"   \/>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/blurred2aIE.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>You can also use this alternate recipe I have used one or twice if you want a darker color closer to the box, with it becoming dramatically lighter father away:<\/p>\n<table class=\"dataTable\">\n<thead>\n<tr>\n<th>Live HTML result<\/th>\n<th>Firefox Screenshot<\/th>\n<th>IE7 Screenshot<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<div id=\"glowShadow2a\">\nThis is another example of a box that has longer blurred shadows horizontally and vertically on all sides.\n<\/div>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/blurred3Firefox.png\"   \/>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/blurred3IE.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Sure, the IE7 screenshot looks slightly different from the Firefox one, but <strong>let&#8217;s take a look at what all the modern browsers look with exactly the same CSS code:<\/strong><\/p>\n<table class=\"dataTable blurredComparison\">\n<thead>\n<tr>\n<th>Opera<\/th>\n<th>IE 9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/blurred2aOpera.png\"   \/>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/blurred2aIE9.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<thead>\n<tr>\n<th>Safari 5<\/th>\n<th>Chrome 13<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/blurred2aSafari.png\"   \/>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/blurred2aChrome.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>They are all slightly different.  It is almost impossible to be pixel perfect with blurred box-shadows unless you give different rules to the different browsers using vendor-specific prefixes.<\/p>\n<p>Two important caveats about the Visual Filter rules:<\/p>\n<ol>\n<li>As mentioned before, the CSS for IE6-8 uses a lighter color for the shadow.  This is due to the way the <code>Shadow<\/code> filter behaves: it requires a lighter shade to simulate the same effect.<\/li>\n<li><strong>Note that the Visual Filters examples are pushed down and to the right compared to the CSS3 example.<\/strong>  This is for the same reasons as stated in <a href=\"#type1b\">Type 1b<\/a>, and a developer would again have to use margins or positioning to get the box in exactly the same place as it is in IE6-8:<br \/>\n<blockquote class=\"code\">\n<pre>\r\n#box {\r\n   box-shadow: 0 0 5px #666666;\r\n   -webkit-box-shadow: 0 0 5px #666666;\r\n   -moz-box-shadow: 0 0 5px #666666;\r\n}   \r\n\r\nbody.ie6 #box,\r\nbody.ie7 #box,\r\nbody.ie8 #box {\r\n<span class=\"hilite\">   margin-left: -5px;\r\n   margin-top: -5px;<\/span>\r\n   zoom: 1;\r\n   filter: progid:DXImageTransform.Microsoft.Shadow(Color=#cccccc, Strength=5, Direction=0),\r\n         progid:DXImageTransform.Microsoft.Shadow(Color=#cccccc, Strength=5, Direction=90),\r\n         progid:DXImageTransform.Microsoft.Shadow(Color=#cccccc, Strength=5, Direction=180),\r\n         progid:DXImageTransform.Microsoft.Shadow(Color=#cccccc, Strength=5, Direction=270);\r\n}\r\n<\/pre>\n<\/blockquote>\n<\/li>\n<\/ol>\n<h3>Type #3: Blurred <code>box-shadow<\/code><\/h3>\n<p>Up until a few days ago, I thought this last type of text-shadow could not be simulated in IE using just CSS.  I then came across <a href=\"http:\/\/css-tricks.com\/snippets\/css\/css-box-shadow\/\">an interesting recipe from CSS-Tricks<\/a> and <a href=\"http:\/\/www.der-schepp.de\/blur-breaker-dropshadow\/\">this demo by Christian \u201dSchepp\u201d Schaefer<\/a>. These CSS recipes came close, but was not able to control the color of the shadow itself (it assumed grey shadows only) or the exact location of the shadow.  I decided to take this work to the next level and add full control of the text-shadow, with some nice results:<\/p>\n<table class=\"dataTable\">\n<thead>\n<tr>\n<th>Live HTML result<\/th>\n<th>Firefox Screenshot<\/th>\n<th>IE7 Screenshot<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<div id=\"blurredShadow\">\n<div class=\"content\">\n                This is an example of a box with a blurred box-shadow.  It uses a special CSS recipe in order for it to work in Internet Explorer 6-8 involving a container HTML element and the Blur Visual Filter.\n        <\/div>\n<\/div>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/blurred4Firefox.png\"   \/>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/blurred4IE.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Here is the HTML:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n&lt;div id=\"box\"&gt;\r\n        &lt;div class=\"content\"&gt;\r\n                This is an example of a box with a blurred box-shadow.  \r\n                It uses a special CSS recipe in order for it to work in \r\n                Internet Explorer 6-8 involving a container HTML element \r\n                and the Blur Visual Filter.\r\n        &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n\r\n<\/pre>\n<\/blockquote>\n<p>and here is the CSS:<\/p>\n<blockquote class=\"code\">\n<pre>\r\n#box {\r\n        \/* CSS3 syntax *\/\r\n\tbox-shadow: 5px 5px <span class=\"hilite2\">5px<\/span> <span class=\"hilite\">#cccccc<\/span>;\r\n\t-webkit-box-shadow: 5px 5px 5px #cccccc;\r\n\t-moz-box-shadow: 5px 5px 5px #cccccc;\r\n\r\n        \/* Place any other shared CSS properties here, except for those in the next rule *\/\r\n        margin: 20px auto;\r\n\ttext-align: center;\r\n}\r\n\r\n#box,\r\nbody.ie6 #box .content,\r\nbody.ie7 #box .content,\r\nbody.ie8 #box .content {\r\n        \/* \r\n         * Any width, height, padding, border and background information goes here, so it is \r\n         * shared between the CSS3 and legacy-IE solutions\r\n         *\/\r\n\twidth: 200px;\t\r\n\tpadding: 10px;\r\n\tbackground: white;\r\n\tborder: solid 1px black;\r\n}\r\n\r\nbody.ie6 #box,\r\nbody.ie7 #box,\r\nbody.ie8 #box {\r\n        \/* This contains the color of the shadow in the CSS3 syntax *\/\r\n\tbackground: <span class=\"hilite\">#cccccc<\/span>;\r\n\r\n        \/* This contains the blur-radius in the CSS3 syntax *\/\r\n\tzoom: 1;\r\n\tfilter: progid:DXImageTransform.Microsoft.Blur(PixelRadius=<span class=\"hilite2\">5<\/span>);\r\n\r\n        \/* You must remove the border in IE, since it will be replaced in the next rule *\/\r\n\tborder: none;\r\n}\r\n\r\nbody.ie6 #box .content,\r\nbody.ie7 #box .content,\r\nbody.ie8 #box .content {\r\n\tposition: relative;\r\n\r\n        \/* \r\n         * Margins must be added here to place the box above the shadow correctly.  \r\n         * The margin-left and margin-right properties should be -2 times the CSS3 x-offset.\r\n         * The margin-top and margin-bottom properties should be -2 times the CSS3 y-offset.\r\n        \/\r\n\tmargin-top: -10px;  \r\n\tmargin-left: -10px;\r\n\tmargin-bottom: -10px;\r\n        margin-right: -10px;\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>Yes, <strong>the Legacy-IE Specific CSS as long and as painful like a meeting with your accountant,<\/strong> but it gets the job done.  <\/p>\n<h2>Conclusion<\/h2>\n<p>These Visual Filters CSS recipes can come handy when you want IE6-8 to have similar box-shadow effects that modern web browsers have.  There are probably other types of box-shadows that can be handled using them, and if you are interested I encourage those with time and patience to check out Microsoft&#8217;s reference to Visual Filters and start playing with them.  Although Visual Filter support will probably be taken out of IE10, developers won&#8217;t need worry since IE9 already has box-shadow support &mdash; these experiments should only be used to add box-shadow support in older versions of IE.<\/p>\n<h2>Further Reading<\/h2>\n<ul>\n<li><a href=\"https:\/\/developer.mozilla.org\/En\/CSS\/Box-shadow\">Mozilla.org&#8217;s <code>box-shadow<\/code> reference page<\/a>\n<li><a href=\"http:\/\/css-tricks.com\/snippets\/css\/css-box-shadow\/\">CSS Box Shadow<\/a> from <a href=\"http:\/\/css-tricks.com\">CSS Tricks<\/a><\/li>\n<li><a href=\"http:\/\/www.der-schepp.de\/blur-breaker-dropshadow\/\">CSS3 Box-Shadow for Legacy IEs<\/a> from <a href=\"http:\/\/twitter.com\/#!\/derSchepp\">Christian \u201dSchepp\u201d Schaefer<\/a><\/li>\n<li><a href=\"http:\/\/robertnyman.com\/2010\/03\/16\/drop-shadow-with-css-for-all-web-browsers\/\">Drop shadow with CSS for all web browsers<\/a> by <a href=\"http:\/\/robertnyman.com\">Robert Nyman<\/a>.  Note his article includes an alternate simpler solution for a blurred <code>box-shadow<\/code> that involves the <code>Shadow<\/code> filter:<br \/>\n<table class=\"dataTable\">\n<thead>\n<tr>\n<th>Live HTML result<\/th>\n<th>Firefox Screenshot<\/th>\n<th>IE7 Screenshot<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<div id=\"shadow4\">\n                This is an example of a box with a blurred box-shadow.  It uses the <code>Shadow<\/code> filter for Internet Explorer 6 through 8.\n<\/div>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/nyman1-Firefox.png\"   \/>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/nyman1-IE.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p> but does not as similar when dealing with large shadows:<\/p>\n<table class=\"dataTable\">\n<thead>\n<tr>\n<th>Live HTML result<\/th>\n<th>Firefox Screenshot<\/th>\n<th>IE7 Screenshot<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<div id=\"shadow4a\">\n                This is an example of a box with a blurred box-shadow.  It uses the <code>Shadow<\/code> filter for Internet Explorer 6 through 8.\n<\/div>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/nyman2-Firefox.png\"   \/>\n<\/td>\n<td>\n<img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/nyman2-IE.png\"   \/>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>This difference may or may not be important to you, and again, I leave it up to the reader to decide what the right solution would be according to the situation.\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.useragentman.com\/blog\/wp-content\/uploads\/2011\/08\/intro.png\" \/> Using CSS3, developers can create <strong>simple<\/strong>, <strong>glowing<\/strong> and <strong>blurred<\/strong> box-shadows in all modern web browsers. <strong>But what about IE6-8?<\/strong>  This article will discuss how you can simulate them using a variety of Visual Filters to simulate them.  This article will cover a few CSS3 box-shadow effects, the equivalent Visual Filter recipes for IE 6-8, and the differences between them.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[126,38,120],"tags":[130,100,131,127,128,129],"class_list":["post-3563","post","type-post","status-publish","format-standard","hentry","category-box-shadow","category-css3","category-ie-visual-filters","tag-chroma","tag-dropshadow","tag-glow","tag-ie6","tag-ie7","tag-ie8"],"_links":{"self":[{"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/posts\/3563","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=3563"}],"version-history":[{"count":174,"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/posts\/3563\/revisions"}],"predecessor-version":[{"id":6271,"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/posts\/3563\/revisions\/6271"}],"wp:attachment":[{"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/media?parent=3563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/categories?post=3563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.useragentman.com\/blog\/wp-json\/wp\/v2\/tags?post=3563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}