Skip to main content
Participant
July 29, 2009
Question

Seperate CSS for IE and FF

  • July 29, 2009
  • 3 replies
  • 916 views

Hi People

I must admit I havent searched the forums but have googled till my eyes bled.

I need to serve a different CSS depending on the browser used to navigate my site. namely IE and Firefox, but a solution for all browser would be tops.

I have tried

     <!--[if IE]>
         <link rel="stylesheet" type="text/css" href="css/mysite_ie.css">
    <![endif]-->

But <!-- --> tends to comment out code on a.cfm page.

All I ask is the CF equvalent for the above code.

I hope im not being hasty by posting this but any help would be appreciated.

Many Thanks

Speedmetall

    This topic has been closed for replies.

    3 replies

    Inspiring
    August 3, 2009

    Greetings Speedmetall,

    Give the following code a try. I use it all the time in my

    web development to handle the differences between

    Internet Explorer and Fire Fox.

    This can be used both in the header section as well as

    the body section

    <!--- Begin - Browser detection --->
    <cfif cgi.HTTP_USER_AGENT contains "MSIE">
    <!--- Begin - Content for Internet Explorer --->

    <!--- End - Content for Internet Explorer --->
    <cfelseif cgi.HTTP_USER_AGENT contains "Mozilla">
    <!--- Begin - Content for Mozilla / FireFox --->

    <!--- End - Content for  Mozilla / FireFox --->
    </cfif>
    <!--- End - Browser detection --->

    Leonard

    Inspiring
    July 30, 2009

    See, e.g.:

    http://www.thesitewizard.com/css/excludecss.shtml

    http://www.webcredible.co.uk/user-friendly-resources/css/hacks-browser-detection.shtml

    Googling "css different browser" produced this and "about 80,800,000 (yeah, right...)" pages.

    Incidentally, I usually employ JavaScript libraries and frameworks which take care of things like browser-checking for you.  Make very sure at all times that you are not needlessly re-inventing any wheels.

    Participant
    July 29, 2009

    I was being too hasty sorry, apparently that does work even though it seems commented out in my code.