Internet Explorer Filters

Internet Explorer Filters are a pure CSS implementation that, when used in conjunction with the HTML5 Boilerplate <html> conditional comments, requires no hacks and (almost) validates perfectly!

Note that this CSS will not validate because filter is invalid. If validation is important to you, this could be served via an IE-only stylesheet.

There are two IE filters that apply something that is supposed to look like a drop-shadow: DropShadow and Shadow. I know, how imaginative…

DropShadow creates a “separated” shadow look, with defined edges:

#example1 {
	-moz-box-shadow: 5px 5px 0 #666; /* FF3.5+ */
	-webkit-box-shadow: 5px 5px 0 #666; /* Saf3.0+, Chrome */
	box-shadow: 5px 5px 0 #666; /* Opera 10.5, IE9+, W3C  */
}
html.lte8 #example1 {
	filter: progid:DXImageTransform.Microsoft.DropShadow(color='#666666',offX='5',offY='5',positive='true'); /* IE6-8 */
	zoom: 1; /* 'hasLayout' required for filter */
}

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Shadow creates a “connected” shadow look, with its edges still connected to the edges of the element, and the closest thing IE filters come to a “soft” edge:

#example2 {
	-moz-box-shadow: 5px 5px  5px #666; /* FF3.5+ */
	-webkit-box-shadow: 5px 5px  5px #666; /* Saf3.0+, Chrome */
	box-shadow: 5px 5px  5px #666; /* Opera 10.5, IE9+, W3C  */
}
html.lte8 #example2 {
	filter: progid:DXImageTransform.Microsoft.Shadow(color='#666666',direction='135',strength='5'); /* IE6-8 */
	zoom: 1; /* 'hasLayout' required for filter */
}

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

One Response to Internet Explorer Filters

Leave a Reply

Your email address will not be published. Required fields are marked *