-1

How do I import an css file for Chrome (or webkit).

I want to do something like this for ie6:

<!--[if lte IE 6]>
  <link rel="stylesheet" type="text/css" href="ie6.css" />
<![endif]-->
WIRN
  • 915
  • 1
  • 16
  • 31
  • http://api.jquery.com/jQuery.browser/ – SRN Jan 22 '13 at 12:33
  • http://stackoverflow.com/questions/1876156/css-hacks-firefox-3-5-and-google-chrome does possible answer your question – Reporter Jan 22 '13 at 12:34
  • Why would you want to do such a thing? Chrome is a grade A browser (see: http://yuilibrary.com/yui/docs/tutorials/gbs/) – cimmanon Jan 22 '13 at 13:01
  • I'm using .net c# so I used did it this way: http://stackoverflow.com/questions/6715806/load-different-css-file-based-on-browser – WIRN Jan 29 '13 at 15:08

2 Answers2

1

Your best, and easiest, bet is using a server-side language that can detect the user's browser. PHP, ColdFusion, JSP, etc have built-in functions and variables that can help you determine the browser a user has.

If not, then a client-side scripting agent is your next option. JavaScript, and its efficient library option, jQuery, are good approaches.

 //jQuery
        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script>
        if ($.browser.webkit) {
            ///Chrome-specific css here.
        }
       </script>

If you can't (or don't know how to) use the library, then the following works as well, but you'll need to do a few more conditional checks

//Javascript (Note: Chrome will say 'Netscape' for its name)
    <script>
    var browserName = window.navigator.appName;
    var browserVersion = window.navigator.appVersion;
    </script>
justacoder
  • 2,684
  • 6
  • 47
  • 78
  • I'm using .net c# so I used did it this way: http://stackoverflow.com/questions/6715806/load-different-css-file-based-on-browser – WIRN Jan 23 '13 at 15:10
0

if you want to only change lines of code instead load a full css file you could use this: http://rafael.adm.br/css_browser_selector/

Ramon Vasconcelos
  • 947
  • 3
  • 14
  • 31