Validating CSS: filter in Firefox
Saturday, August 18th, 2007Categories: Troubleshooting
RSS Comment Feed
Trackback
If you’re like me and you’re using the Web Developer toolbar, you like it when your site validates in it.
If you’re looking to do some AJAX/Javascript effects, for example, where a semi-transparent color (I call them blankets) are put over a background while you pop up a member login, you’ll need to use the filter and opacity css attributes. (Note: If you don’t know what I’m talking about in my example, go to Text-Link-Ads.com and click on Member login)
What your code looked like
Example, We currently have our Div container that we want to make transparent, with an opacity of 65%. This is what the CSS code would look like:
#blanket {
background-color:#111;
filter:alpha(opacity=65);
opacity: 0.65;
}
This returns and error in the Firefox toolbar and doesn’t validate as proper CSS. In your Web Developer toolbar, you got:
Unknown property ‘filter’. Declaration dropped
What’s the solution? Internet Explorer has a built-in function where you can script code that only Internet Explorer browsers can see, and this does not affect any other browsers.
First off, go ahead and comment out the filter attribute in your CSS file:
#blanket {
background-color:#111;
/*filter:alpha(opacity=65);*/
opacity: 0.65;
}
In your HTML file, type the following:
<!–[if IE]>
<style type=”text/css”>
#blanket {filter:alpha(opacity=65);}
</style>
<![endif]–>
When using this syntax, the contents of the comment will only be displayed if the visitor is using Internet Explorer, thus, you can have a site that validates in the Web Developer toolbar, and still works for Internet Explorer users. I will discuss more details around the syntax at a later date.
Good luck.

Related Posts
- Why You Should Validate Your Website
- Devil’s Advocate – Why You SHOULD’NT Validate Your Website
- The Only Firefox Add-On You’ll Ever Need


January 26th, 2008 at 10:43 pm
but isn’t there any solution to this in mozilla firefox?
January 27th, 2008 at 12:56 am
Firefox is okay with using just opacity: 0.65, it’s the filter attribute that Firefox’s built-in validator doesn’t like.
March 14th, 2008 at 12:07 pm
great thanks! simple and clear!
May 22nd, 2008 at 2:26 am
this may be a solution that I see with FF. I have a routine which works in both IE and FF BUT it is FF that displays or indicates an error namely, filter. below is my routine
How can I eliminate this error in FF, as I am not sure since I am using the onmouseover/out events.
I would deeply appreciate any help you may offer.
thanks
August 18th, 2009 at 10:29 am
great idea
thats it
i´m looking a long time for this fucking two lines
great work and brain
greetz
July 21st, 2010 at 12:56 pm
this is ok, but! what about if you ahve many filer for different stuff on the page, then you end up with a bunch of filter coded for IE….. yes the developer toolbar tell you there is an error but this doesn’t affect your site…. f__k it!
October 30th, 2010 at 8:18 am
can I get the list of filters that can be used in firefox ..