A partial-filter (hack) for CSS for the Firefox browser?

Writing

The Writing ‘A partial-filter (hack) for CSS for the Firefox browser?’ was added on November 9th, 2006. It's filed under: CSS, Design.

Writings

Please comment if you know this filter (okay, partial-filter) is already in use elsewhere so I can go away with my tail between my legs. Or, if you think you know about CSS filters and do not know of this one and suspect I may have discovered it then please comment here to let me know (thanks).

Of course, I am assuming this is well known and I will be heartily embarrassed when I discover that I have not stumbled on something, but rather, simply stumbled ;)

The filter

This filter, so far from my initial tests, stops Firefox from reading a CSS rule involving units.

Let’s say we wanted the IE and Firefox people to see an h3 block of a certain size. We might have the following laughably simple rule:

h3 {
font-size: 1.5em;
}

To apply the filter we simply add an empty comment block before the unit, thus:

h3 {
font-size: 1.5/**/em;
}

The result is that IE6 and IE7 will read the rule as you might expect and Firefox will ignore it. So far this has been tested with Firefox 1.5X on Win and Firefox 2.0 (beta) on Mac OSX.

With a truly narcissistic dab at my keyboard and to ensure I certainly find this filter is not my discovery (because life’s like that eh?), I will name my filter: partiALfox.

  1. AgentDrex

    My suggestion would be to move the empty comment block to another area such as between the “f” and “o” of “font”. If Firefox ignores the rule like before, then it may be safe to assume this behavior is due to the fact that Firefox is fairly code-compliant dependent. Like when you leave out the hash mark from in front of a hex color code. Firefox will ignore the rule. Internet Explorer is a slacker browser. It comes across errors and goes “eh…whatever…” and display it…which leads you to believe the page is coded correctly when it is not exactly w3c compliant. Such it is. I like the style and simplicity of your page…awesome…good job

    Fri Dec 15 2006 at 12:47 am
  2. Alan

    It seems the empty comment mid-way through the property does not make Firefox ignore the rule and then neither does IE6, they behave the same. So it’s no longer a filter for Firefox (from my quick and dirty test). Moving the comment back to the value, just before the unit returns it to being a filter for Firefox (ie Firefox now ignores the rule and IE6 does not ignore it).

    Sound very much as if it’s sloppyness in IE that is being exposed, but what I was interested in particularly was, was it a filter for Firefox (or partial one) and the narcissist in me was interested in whether I was the first to find or publish it. But then again, who cares, there’s more to life eh?

    =)

    Thanks for your comment AgentDrex.

    Fri Dec 15 2006 at 3:45 am
Infrequent & occasionally good

Big up fluffDESIGN at Add to Technorati Favorites