CSS hack for Firefox only

I have been in a few situations (very few) where I want a page to look different in Firefox. Here’s a little snippet of how you could code it. Please note that this CSS will not validate but will work perfectly fine.

/*"className" is your class or ID*/
/*FireFox 2 */
.className, x:-moz-any-link {font-weight:bold;} 

/*FireFox 3*/
.className, x:-moz-any-link, x:default {font-weight:bold;}

Have you encountered any other hacks for firefox?

Update: Please note that you may have to write a hack for IE7

10 Comments

  1. Jatin Meshiya
    Posted September 18, 2008 at 1:55 am | Permalink

    this code is not working!!! why give us a perfect solution otherwise pls dont waste others time. please it is a request. please

  2. Ashli M
    Posted September 23, 2008 at 7:26 am | Permalink

    This code is not working for me either. The styles that are changed in the FF hack still show up in IE too.

  3. Nash K
    Posted October 1, 2008 at 12:54 am | Permalink

    This does not work. Why post this?

  4. Posted October 2, 2008 at 12:37 am | Permalink

    Try adding html>/**/body before your class/id name.
    Ex.
    html>/**/body .className, x:-moz-any-link, x:default {font-weight:bold;}
    for ff3.

  5. Posted October 3, 2008 at 7:52 pm | Permalink

    The first rule applies to FF2+ and IE7+. The second applies to FF3+ and IE7+. Therefore the post title is inaccurate (along with various other posts elsewhere).

    Another useful hack I just spotted; FF2 on Windows is case-insensitive for attribute selectors (I’ve only tested with ID attribute). This allows rules that target FF2 and below only:

    #rabbit[id=rabbit] { /* FF+ and IE7+ */ }
    #rabbit[id=raBbit] { /* FF2 and below only */ }

    Cheers, BJ

  6. Pooks
    Posted October 14, 2008 at 7:51 am | Permalink

    This was useful for me. Isolate the version of Firefox you want to with this hack and then correct it for IE7 using the usual conditional comment.

  7. CW
    Posted November 18, 2008 at 11:55 am | Permalink

    The FF2 hack worked for me fine.

  8. Posted November 18, 2008 at 1:57 pm | Permalink

    Hi,

    if you want only FF to do a special thing, use the lines above and after that an IE hack. To back it bold except FF:

    /* All browsers */
    .className, x:-moz-any-link {font-weight:normal;}

    /*FireFox 2 and IE7 */
    .className, x:-moz-any-link {font-weight:bold;}

    /*FireFox 3 and IE7 */
    .className, x:-moz-any-link, x:default {font-weight:bold;}

    /* IE */
    .className {_font-weight:normal; #font-weight:normal;}

    Regards

  9. Posted November 18, 2008 at 1:58 pm | Permalink

    Sorry, of course it must be

    * All browsers */
    .className {font-weight:normal;}

  10. argishtv
    Posted November 24, 2008 at 3:40 pm | Permalink

    hello Jatin Meshiya email me at ssdf11@gmail.com i have a favor to ask you need some work done on my site please contact me

One Trackback

  1. By jmhjalzg on November 7, 2008 at 9:57 pm

    jmhjalzg…

    jmhjalzg…

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*
vpn service