Title: browser detection then swapping css&#8230;.
Last modified: August 18, 2016

---

# browser detection then swapping css….

 *  [mentaleruptions](https://wordpress.org/support/users/mentaleruptions/)
 * (@mentaleruptions)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/browser-detection-then-swapping-css/)
 * Im looking for a way to change the css file thats loaded depending on the browser
   the blog is viewed from. Ive searched the net and these forums and found a few
   ways but nothing seams to work.
 * This is what i currently have and it doesnt do what it should:
 * <link rel=”stylesheet” href=”[http://mywebsite.com/wp-content/themes/mytheme/style.css&#8221](http://mywebsite.com/wp-content/themes/mytheme/style.css&#8221);
   type=”text/css” media=”screen” />
    <!–[if IE 6]> <link rel=”stylesheet” href=”
   [http://mywebsite.com/wp-content/themes/mytheme/iestyle.css&#8221](http://mywebsite.com/wp-content/themes/mytheme/iestyle.css&#8221);
   type=”text/css” media=”screen” /> <![endif]–>
 * For some reason IE doesnt bypass the first link to the style.css file and just
   loads it. However if i remove the first link to style.css then IE loads the iestyle.
   css and firefox doesnt load any css file.
 * Anyone got any clues what im doing wrong with this code ??
 * Thanks,
 * Tom

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [petit](https://wordpress.org/support/users/petit/)
 * (@petit)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/browser-detection-then-swapping-css/#post-450289)
 * I haven’t tested it my self, but maybe this is the answer:
    [Browser Dependent Cascading Style Sheets (CSS) in PHP](http://www.casualcode.com/browser_dependent_cascading_style_sheets.html)
 *  [petit](https://wordpress.org/support/users/petit/)
 * (@petit)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/browser-detection-then-swapping-css/#post-450297)
 * ….?
 *  Thread Starter [mentaleruptions](https://wordpress.org/support/users/mentaleruptions/)
 * (@mentaleruptions)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/browser-detection-then-swapping-css/#post-450340)
 * Thanks petit,
 * Ive not had chance to test it but will let you know once i do.
 * Tom
 *  Thread Starter [mentaleruptions](https://wordpress.org/support/users/mentaleruptions/)
 * (@mentaleruptions)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/browser-detection-then-swapping-css/#post-450349)
 * <?php
 * $browser = get_browser();
 * $css_file = ($browser->browser == ‘Firefox’ && $browser->version == 1.0) ? ‘[http://mywebsite.com/wp-content/themes/mytheme/style.css&#8217](http://mywebsite.com/wp-content/themes/mytheme/style.css&#8217);:‘
   [http://mywebsite.com/wp-content/themes/mytheme/iestyle.css&#8217](http://mywebsite.com/wp-content/themes/mytheme/iestyle.css&#8217);;
 * echo ‘<link rel=”stylesheet” type=”text/css” href=”‘ . $css_file . ‘” />’;
 * ?>
 * Well ive installed the browscap.ini and have set the code up like above to detect
   browser. However i can only get one or the other to show up but not both. Ive
   tried it detecting internet explorer and firefox but neither seam to work.
 * Tom
 *  [petit](https://wordpress.org/support/users/petit/)
 * (@petit)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/browser-detection-then-swapping-css/#post-450391)
 * If you are using Firefox 1.5, the above code should give you “iestyle.css”, and
   I suppose you don’t use the old 1.0. I’m not yet a PHP savvy guy, so I don’t 
   know about browscap.ini and its use. Maybe someone else can jump in here.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘browser detection then swapping css….’ is closed to new replies.

 * 5 replies
 * 2 participants
 * Last reply from: [petit](https://wordpress.org/support/users/petit/)
 * Last activity: [19 years, 8 months ago](https://wordpress.org/support/topic/browser-detection-then-swapping-css/#post-450391)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
