These hacks don't validate, but are 100% safe according to CSS parsing rules.

Before you hack anything, make sure you're hacking because of a browser bug, not because you failed to understand how particular CSS feature should work. Check the specification and compare results with Opera and Safari first!

Firefox 2.0 or older

If you need to make pre-Acid2 Firefox behave, you can safely use this:

#hackme, x:-moz-any-link {styles for Firefox 2.0 here}
#hackme, x:-moz-any-link, x:default {restore styles for Firefox 3.0 and newer}

This hack will apply rules to #hackme element. You can change the first selector (#hackme) in each rule to anything else, but don't touch the ones with x.


For 9 versions support for inline-block in Gecko was FUBAR. The closest equivalent wouldn't respect line-height. The workaround:

#menu a {display:inline-block; line-height:2em;}
#menu a, x:-moz-any-link {display:-moz-inline-box; padding-top:0.5em;}
#menu a, x:-moz-any-link, x:default {display:inline-block; padding-top:0;}

Firefox 1.0 or older

#hackme, x:-moz-any-link {styles for Firefox 1.0 here}
#hackme, x:-moz-any-link, x:only-child {restore normal styles for newer versions}

Same as above — you can change #hackme to whatever you need, but leave other selectors in the same group as they are.

How do these work?

If you have multiple IE versions installed, CSS parsing in IE7 may be broken and this hack may not work. It works fine in real IEs in standards mode (tested 6, 7, 8, including IE7 mode in IE8).

CSS error handling rules require browsers to drop entire rule if any of the selectors is not recognized. :-moz-any-link is a selector private to Gecko, so all non-Gecko browsers see it as parse error. :default has been added in Firefox 3.0 (Gecko 1.9), :only-child has been added in Firefox 1.5, so they're unknown to earlier versions of Firefox/Gecko.

There's more of these. If you want to adapt hack for newer Gecko version, find suitably recent Gecko extensions.